Right-click to run PyUnit test works with pytest parametrized tests.
@@ -117,6 +117,11 @@ def pytest_collection_modifyitems(session, config, items):
# print('Skip file: %s' % (f,))
continue # Skip the file
+ i = name.find('[')
+ name_without_parametrize = None
+ if i > 0:
+ name_without_parametrize = name[:i]
+
accept_tests = py_test_accept_filter[f]
if item.cls is not None:
@@ -124,21 +129,28 @@ def pytest_collection_modifyitems(session, config, items):
else:
class_name = None
for test in accept_tests:
- # This happens when parameterizing pytest tests.
- i = name.find('[')
- if i > 0:
- name = name[:i]
if test == name:
# Direct match of the test (just go on with the default
# loading)
new_items.append(item)
break
+ if name_without_parametrize is not None and test == name_without_parametrize:
+ # This happens when parameterizing pytest tests on older versions
+ # of pytest where the test name doesn't include the fixture name
+ # in it.
+ new_items.append(item)
+ break
+
if class_name is not None:
if test == class_name + '.' + name:
new_items.append(item)
break
+ if name_without_parametrize is not None and test == class_name + '.' + name_without_parametrize:
+ new_items.append(item)
+ break
+
if class_name == test:
new_items.append(item)
break
