Skip to content

Commit

Permalink
Don't modify nodeid when plugin is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
kondratyev-nv committed Dec 27, 2020
1 parent 632e126 commit cda6b68
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pytest_pspec/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,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():
Expand Down

0 comments on commit cda6b68

Please sign in to comment.