Skip to content

Commit

Permalink
Skip tests generated by plugins (like pep8) for discovery command.
Browse files Browse the repository at this point in the history
To do not fail on discovery command and do not track their results.
  • Loading branch information
Pavel Zaikin committed Oct 28, 2019
1 parent acd7a3d commit a40d34b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions news/2 Fixes/7287.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Discovering tests failed when pytest plugins generate tests (like pep8).
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 a40d34b

Please sign in to comment.