Skip to content

Skip tests generated by plugins (like pep8) for discovery command. #8242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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