diff options
author | Daniel Hahler <git@thequod.de> | 2018-11-07 11:01:39 +0100 |
---|---|---|
committer | Daniel Hahler <git@thequod.de> | 2018-11-07 11:01:39 +0100 |
commit | 134b103605ffbe50ea5175cfeecb8d033458fbd0 (patch) | |
tree | 68dc96ef7a9c0d4c5607a5e021dd74a8a73ca64a | |
parent | fa35f650b53821baa85c78caf116fd9e4522c408 (diff) | |
download | pytest-134b103605ffbe50ea5175cfeecb8d033458fbd0.tar.gz |
XXX: revert _collect_seen_pkgdirs
-rw-r--r-- | src/_pytest/main.py | 7 | ||||
-rw-r--r-- | 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): "<Package *", " <Module '__init__.py'>", " <Function 'test_init'>", + "<Module 'tests/test_foo.py'>", + " <Function 'test_foo'>", + ] + ) + # XXX: Same as before, but different order. + result = testdir.runpytest(".", "tests", "--collect-only") + result.stdout.fnmatch_lines( + [ + "collected 2 items", + "<Package *", + " <Module '__init__.py'>", + " <Function 'test_init'>", + "<Package *", " <Module 'test_foo.py'>", " <Function 'test_foo'>", ] |