pytest icon indicating copy to clipboard operation
pytest copied to clipboard

pytest main does not detect some invalid nodeid names

Open elbehery95 opened this issue 3 years ago • 0 comments

Test scenario

test_file.py

import pytest

@pytest.mark.parametrize("bar", [1,2,3])
def test_foo(bar):
    print(bar)

The following invalid nodeid is accepted by pytest instead of printing an error

$ pytest "test_file.py[foobar]" -q

...        [100%]
3 passed in 0.04s

Expected

Similar to specifying wrong path/dir/parameterized nodeid an error should be printed instead of running all the tests in the given file

$ pytest "test_file.py[foobar]" -q

no tests ran in 0.01s
ERROR: file or directory not found: test_hello.py[foobar]

elbehery95 avatar Sep 05 '22 19:09 elbehery95