Skip to content

Commit f551cb9

Browse files
committed
Skip Instances with --collect-only
1 parent 87254ca commit f551cb9

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

changelog/4358.removal.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ it was not really possible to detect when the functionality was being used expli
1414
The extra ``::()`` might have been removed in some places internally already,
1515
which then led to confusion in places where it was expected, e.g. with
1616
``--deselect`` (`#4127 <https://github.com/pytest-dev/pytest/issues/4127>`_).
17+
18+
Test class instances are also not listed with ``--collect-only`` anymore.

src/_pytest/terminal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,8 @@ def _printcollecteditems(self, items):
617617
stack.pop()
618618
for col in needed_collectors[len(stack) :]:
619619
stack.append(col)
620-
# if col.name == "()":
621-
# continue
620+
if col.name == "()": # Skip Instances.
621+
continue
622622
indent = (len(stack) - 1) * " "
623623
self._tw.line("%s%s" % (indent, col))
624624

testing/python/collect.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,9 +1408,7 @@ def test_hello(self):
14081408
"""
14091409
)
14101410
result = testdir.runpytest("--collect-only")
1411-
result.stdout.fnmatch_lines(
1412-
["*MyClass*", "*MyInstance*", "*MyFunction*test_hello*"]
1413-
)
1411+
result.stdout.fnmatch_lines(["*MyClass*", "*MyFunction*test_hello*"])
14141412

14151413

14161414
def test_unorderable_types(testdir):

0 commit comments

Comments
 (0)