From e0e5e9a2cd954cdb0a6c47a8565863fb9f4a63c0 Mon Sep 17 00:00:00 2001 From: Niranjan M.R Date: May 21 2018 13:42:18 +0000 Subject: Add support to generate testcase names for parametrized test cases Fixes Issue: #8 Signed-off-by: Niranjan M.R --- diff --git a/pytest_modifyjunit/plugin.py b/pytest_modifyjunit/plugin.py index d3f74d1..ba18bca 100644 --- a/pytest_modifyjunit/plugin.py +++ b/pytest_modifyjunit/plugin.py @@ -60,6 +60,14 @@ class ModifyJunit(object): outcome = yield rep = outcome.get_result() title_regex = re.compile("^.[T|t]itle\s*:\s*.*") + # Get Id list + try: + test_ids = item.__dict__['callspec']._idlist + except KeyError: + test_params = '' + else: + # convert the list to strings + test_params = ''.join(test_ids) if item._obj.__doc__: doc_strings = item._obj.__doc__.strip() doc_list = re.sub('(\n\s*[:|@][A-Za-z0-9_-]*:)', '\n\\1', @@ -88,7 +96,7 @@ class ModifyJunit(object): tc_title = ' '.join([tc.strip() for tc in doc_list[tc_start: tc_end]]) else: tc_title = ''.join(doc_list[tc_start]) - tc_name = re.sub("^.[T|t]itle\s*:\s*", "", tc_title) + tc_name = re.sub("^.[T|t]itle\s*:\s*", "", tc_title + ' ' + test_params) rep.nodeid = '::'.join(rep.nodeid.split('::')[0:-1]) + \ '::' + tc_name if 'call' in rep.when: diff --git a/setup.py b/setup.py index d09b834..4b2399f 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ with io.open('README.rst', 'rt', encoding='utf-8') as f: setup_args = dict( name = "pytest-modifyjunit", - version = "1.2", + version = "1.3", description = "Utility for adding additional properties to junit xml for IDM QE", long_description = readme_contents, license = "GPL", diff --git a/test/a.xml b/test/a.xml index dd33ba1..b71df0a 100644 --- a/test/a.xml +++ b/test/a.xml @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/test/conftest.py b/test/conftest.py new file mode 100644 index 0000000..157d9ad --- /dev/null +++ b/test/conftest.py @@ -0,0 +1,9 @@ +import pytest + +data = [[2, 3], [3, 2]] + +@pytest.fixture(params=data, ids=["2 users 3 runs", "3 users 2 runs"]) +def load_data(request): + return request.param + + diff --git a/test/test_0001.py b/test/test_0001.py index bfccf2e..b349a6a 100644 --- a/test/test_0001.py +++ b/test/test_0001.py @@ -127,3 +127,17 @@ class TestClass1(object): """ pass + def test_000018(self, load_data): + """ + :title: IDM-SSSD-TC: Feature: Test performance tests with + """ + pass + @pytest.mark.parametrize("test_input, expected", [ + (3, 8), + (4, 6), + ]) + def test_000019(self, test_input, expected): + """ + :title: Testing input is less than expected + """ + assert test_input < expected