Skip to content

Commit 2f776cd

Browse files
committed
Skip tests generated by plugins (like pep8) for discovery command.
To do not fail on discovery command and do not track their results.
1 parent fcaa584 commit 2f776cd

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

news/2 Fixes/7287.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Discovering tests failed when pytest plugins generate tests (like pep8).

pythonFiles/testing_tools/adapter/pytest/_discovery.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ def pytest_collection_modifyitems(self, session, config, items):
7878
self._tests.reset()
7979
for item in items:
8080
test, parents = self.parse_item(item)
81-
self._tests.add_test(test, parents)
81+
if test is not None:
82+
self._tests.add_test(test, parents)
8283

8384
# This hook is not specified in the docs, so we also provide
8485
# the "modifyitems" hook just in case.
@@ -92,4 +93,5 @@ def pytest_collection_finish(self, session):
9293
self._tests.reset()
9394
for item in items:
9495
test, parents = self.parse_item(item)
95-
self._tests.add_test(test, parents)
96+
if test is not None:
97+
self._tests.add_test(test, parents)

pythonFiles/testing_tools/adapter/pytest/_pytest_item.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ def parse_item(item, #*,
152152
"""
153153
#_debug_item(item, showsummary=True)
154154
kind, _ = _get_item_kind(item)
155+
# Skip plugin generated tests
156+
if kind is None:
157+
return None, None
155158
(nodeid, parents, fileid, testfunc, parameterized
156159
) = _parse_node_id(item.nodeid, kind)
157160
# Note: testfunc does not necessarily match item.function.__name__.

0 commit comments

Comments
 (0)