From 134b103605ffbe50ea5175cfeecb8d033458fbd0 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 7 Nov 2018 11:01:39 +0100 Subject: [PATCH] XXX: revert _collect_seen_pkgdirs --- src/_pytest/main.py | 7 +++---- testing/test_collection.py | 13 +++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/_pytest/main.py b/src/_pytest/main.py index 46228f824..a2b27d9fa 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -387,7 +387,6 @@ class Session(nodes.FSCollector): self._initialpaths = frozenset() # Keep track of any collected nodes in here, so we don't duplicate fixtures self._node_cache = {} - self._collect_seen_pkgdirs = set() self.config.pluginmanager.register(self, name="session") @@ -505,7 +504,6 @@ class Session(nodes.FSCollector): if parent.isdir(): pkginit = parent.join("__init__.py") if pkginit.isfile(): - self._collect_seen_pkgdirs.add(parent) if pkginit in self._node_cache: root = self._node_cache[pkginit][0] else: @@ -531,12 +529,13 @@ class Session(nodes.FSCollector): def filter_(f): return f.check(file=1) + seen_dirs = set() for path in argpath.visit( fil=filter_, rec=self._recurse, bf=True, sort=True ): dirpath = path.dirpath() - if dirpath not in self._collect_seen_pkgdirs: - self._collect_seen_pkgdirs.add(dirpath) + if dirpath not in seen_dirs: + seen_dirs.add(dirpath) pkginit = dirpath.join("__init__.py") if pkginit.exists() and parts(pkginit.strpath).isdisjoint(paths): for x in root._collectfile(pkginit): diff --git a/testing/test_collection.py b/testing/test_collection.py index dd8ecb1af..c7cde090e 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -978,6 +978,19 @@ def test_collect_init_tests(testdir): "", " ", + "", + " ", + ] + ) + # XXX: Same as before, but different order. + result = testdir.runpytest(".", "tests", "--collect-only") + result.stdout.fnmatch_lines( + [ + "collected 2 items", + "", + " ", + "", " ", ]