-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Node: do not add "::()" to nodeid #4358
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Remove the ``::()`` notation to denote a test class instance in node ids. | ||
|
||
Previously, node ids that contain test instances would use ``::()`` to denote the instance like this:: | ||
|
||
test_foo.py::Test::()::test_bar | ||
|
||
The extra ``::()`` was puzzling to most users and has been removed, so that the test id becomes now:: | ||
|
||
test_foo.py::Test::test_bar | ||
|
||
This change could not accompany a deprecation period as is usual when user-facing functionality changes because | ||
it was not really possible to detect when the functionality was being used explicitly. | ||
|
||
The extra ``::()`` might have been removed in some places internally already, | ||
which then led to confusion in places where it was expected, e.g. with | ||
``--deselect`` (`#4127 <https://github.com/pytest-dev/pytest/issues/4127>`_). | ||
|
||
Test class instances are also not listed with ``--collect-only`` anymore. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -274,16 +274,26 @@ def test_deselect(testdir): | |
testdir.makepyfile( | ||
test_a=""" | ||
import pytest | ||
|
||
def test_a1(): pass | ||
|
||
@pytest.mark.parametrize('b', range(3)) | ||
def test_a2(b): pass | ||
|
||
class TestClass: | ||
def test_c1(self): pass | ||
|
||
def test_c2(self): pass | ||
""" | ||
) | ||
result = testdir.runpytest( | ||
"-v", "--deselect=test_a.py::test_a2[1]", "--deselect=test_a.py::test_a2[2]" | ||
"-v", | ||
"--deselect=test_a.py::test_a2[1]", | ||
"--deselect=test_a.py::test_a2[2]", | ||
"--deselect=test_a.py::TestClass::test_c1", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we should still support the old syntax, but figured it would not be worth it really. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree it is not worth supporting the old syntax. 👍 |
||
) | ||
assert result.ret == 0 | ||
result.stdout.fnmatch_lines(["*2 passed, 2 deselected*"]) | ||
result.stdout.fnmatch_lines(["*3 passed, 3 deselected*"]) | ||
for line in result.stdout.lines: | ||
assert not line.startswith(("test_a.py::test_a2[1]", "test_a.py::test_a2[2]")) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw: I would really prefer if black would not make a) the diff unnecessarily bigger here by merging this into a single line, and b) keep it for readability. psf/black#601