diff --git a/changelog/4358.removal.rst b/changelog/4358.removal.rst index 1a562cfe7..d66fd483b 100644 --- a/changelog/4358.removal.rst +++ b/changelog/4358.removal.rst @@ -14,3 +14,5 @@ it was not really possible to detect when the functionality was being used expli 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 `_). + +Test class instances are also not listed with ``--collect-only`` anymore. diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index 520caf862..f19325088 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -617,8 +617,8 @@ class TerminalReporter(object): stack.pop() for col in needed_collectors[len(stack) :]: stack.append(col) - # if col.name == "()": - # continue + if col.name == "()": # Skip Instances. + continue indent = (len(stack) - 1) * " " self._tw.line("%s%s" % (indent, col)) diff --git a/testing/python/collect.py b/testing/python/collect.py index 61039a506..ffe4a7271 100644 --- a/testing/python/collect.py +++ b/testing/python/collect.py @@ -1408,9 +1408,7 @@ def test_customize_through_attributes(testdir): """ ) result = testdir.runpytest("--collect-only") - result.stdout.fnmatch_lines( - ["*MyClass*", "*MyInstance*", "*MyFunction*test_hello*"] - ) + result.stdout.fnmatch_lines(["*MyClass*", "*MyFunction*test_hello*"]) def test_unorderable_types(testdir):