Skip to content

Commit

Permalink
Move handling of duplicate files
Browse files Browse the repository at this point in the history
This removes the hack added in
pytest-dev#3802.
  • Loading branch information
blueyed committed Oct 25, 2018
1 parent f466105 commit 465fed9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
19 changes: 10 additions & 9 deletions src/_pytest/main.py
Expand Up @@ -278,15 +278,6 @@ def pytest_ignore_collect(path, config):
if _in_venv(path) and not allow_in_venv:
return True

# Skip duplicate paths.
keepduplicates = config.getoption("keepduplicates")
duplicate_paths = config.pluginmanager._duplicatepaths
if not keepduplicates:
if path in duplicate_paths:
return True
else:
duplicate_paths.add(path)

return False


Expand Down Expand Up @@ -556,6 +547,16 @@ def _collectfile(self, path):
if not self.isinitpath(path):
if ihook.pytest_ignore_collect(path=path, config=self.config):
return ()

# Skip duplicate paths.
keepduplicates = self.config.getoption("keepduplicates")
if not keepduplicates:
duplicate_paths = self.config.pluginmanager._duplicatepaths
if path in duplicate_paths:
return ()
else:
duplicate_paths.add(path)

return ihook.pytest_collect_file(path=path, parent=self)

def _recurse(self, path):
Expand Down
9 changes: 0 additions & 9 deletions src/_pytest/python.py
Expand Up @@ -554,15 +554,6 @@ def isinitpath(self, path):
return path in self.session._initialpaths

def collect(self):
# XXX: HACK!
# Before starting to collect any files from this package we need
# to cleanup the duplicate paths added by the session's collect().
# Proper fix is to not track these as duplicates in the first place.
for path in list(self.session.config.pluginmanager._duplicatepaths):
# if path.parts()[:len(self.fspath.dirpath().parts())] == self.fspath.dirpath().parts():
if path.dirname.startswith(self.name):
self.session.config.pluginmanager._duplicatepaths.remove(path)

this_path = self.fspath.dirpath()
init_module = this_path.join("__init__.py")
if init_module.check(file=1) and path_matches_patterns(
Expand Down

0 comments on commit 465fed9

Please sign in to comment.