Skip to content

Commit

Permalink
Skip tests generated by pytest plugins during discovery. (#8242)
Browse files Browse the repository at this point in the history
For #7287.
  • Loading branch information
zztalker authored and ericsnowcurrently committed Nov 6, 2019
1 parent 96d19a5 commit 355a325
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions news/2 Fixes/7287.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
During test discovery, ignore tests generated by pytest plugins (like pep8).
Tests like that were causing discovery to fail.
6 changes: 4 additions & 2 deletions pythonFiles/testing_tools/adapter/pytest/_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def pytest_collection_modifyitems(self, session, config, items):
self._tests.reset()
for item in items:
test, parents = self.parse_item(item)
self._tests.add_test(test, parents)
if test is not None:
self._tests.add_test(test, parents)

# This hook is not specified in the docs, so we also provide
# the "modifyitems" hook just in case.
Expand All @@ -92,4 +93,5 @@ def pytest_collection_finish(self, session):
self._tests.reset()
for item in items:
test, parents = self.parse_item(item)
self._tests.add_test(test, parents)
if test is not None:
self._tests.add_test(test, parents)
3 changes: 3 additions & 0 deletions pythonFiles/testing_tools/adapter/pytest/_pytest_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ def parse_item(item, #*,
"""
#_debug_item(item, showsummary=True)
kind, _ = _get_item_kind(item)
# Skip plugin generated tests
if kind is None:
return None, None
(nodeid, parents, fileid, testfunc, parameterized
) = _parse_node_id(item.nodeid, kind)
# Note: testfunc does not necessarily match item.function.__name__.
Expand Down

0 comments on commit 355a325

Please sign in to comment.