diff --git a/pytest_pspec/plugin.py b/pytest_pspec/plugin.py index 43f9c7c..777c2d6 100644 --- a/pytest_pspec/plugin.py +++ b/pytest_pspec/plugin.py @@ -31,6 +31,9 @@ def pytest_configure(config): def pytest_collection_modifyitems(config, items): + if not config.option.pspec: + return + for item in items: node = item.obj parent = item.parent.obj diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 3dbb758..deea2b0 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -25,6 +25,17 @@ def test_a_feature_is_working(): expected = '\033[92m ✓ a feature is working\033[0m' assert expected in result.stdout.str() + def test_should_not_modify_nodeid_when_disabled_test(self, testdir): + testdir.makepyfile(""" + def test_a_feature_is_working(): + assert True + """) + + result = testdir.runpytest('-v') + + expected = 'test_should_not_modify_nodeid_when_disabled_test.py::test_a_feature_is_working' + assert expected in result.stdout.str() + def test_should_print_a_red_failing_test(self, testdir): testdir.makepyfile(""" def test_a_failed_test_of_a_feature():