Skip to content

Commit

Permalink
Handle dirs only once
Browse files Browse the repository at this point in the history
Time: 5.73s/5.88s => 5.36s

(Before rebase: 4.86s => 4.45s)
  • Loading branch information
blueyed committed Nov 2, 2018
1 parent 2b50911 commit 6ffa347
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/_pytest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,16 +529,20 @@ def filter_(f):
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
):
pkginit = path.dirpath().join("__init__.py")
if pkginit.exists() and not any(
x in parts(pkginit.strpath) for x in paths
):
for x in root._collectfile(pkginit):
yield x
paths.append(x.fspath.dirpath())
dirpath = path.dirpath()
if dirpath not in seen_dirs:
seen_dirs.add(dirpath)
pkginit = dirpath.join("__init__.py")
if pkginit.exists() and not any(
x in parts(pkginit.strpath) for x in paths
):
for x in root._collectfile(pkginit):
yield x
paths.append(x.fspath.dirpath())

if not any(x in parts(path.strpath) for x in paths):
for x in root._collectfile(path):
Expand Down

0 comments on commit 6ffa347

Please sign in to comment.