diff --git a/news/2 Fixes/7287.md b/news/2 Fixes/7287.md new file mode 100644 index 000000000000..8f47a5e12e11 --- /dev/null +++ b/news/2 Fixes/7287.md @@ -0,0 +1,2 @@ +During test discovery, ignore tests generated by pytest plugins (like pep8). +Tests like that were causing discovery to fail. diff --git a/pythonFiles/testing_tools/adapter/pytest/_discovery.py b/pythonFiles/testing_tools/adapter/pytest/_discovery.py index 39685067c601..23eb1ee282f0 100644 --- a/pythonFiles/testing_tools/adapter/pytest/_discovery.py +++ b/pythonFiles/testing_tools/adapter/pytest/_discovery.py @@ -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. @@ -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) diff --git a/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py b/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py index 56543ee8b13d..781d3c831c06 100644 --- a/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py +++ b/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py @@ -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__.