Skip to content

Commit 7bb504b

Browse files
committed
pytest.main: collect: factor out _visit_filter
1 parent ea73246 commit 7bb504b

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/_pytest/main.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -550,19 +550,9 @@ def _collect(self, arg):
550550
if argpath.check(dir=1):
551551
assert not names, "invalid arg %r" % (arg,)
552552

553-
if six.PY2:
554-
555-
def filter_(f):
556-
return f.check(file=1) and not f.strpath.endswith("*.pyc")
557-
558-
else:
559-
560-
def filter_(f):
561-
return f.check(file=1)
562-
563553
seen_dirs = set()
564554
for path in argpath.visit(
565-
fil=filter_, rec=self._recurse, bf=True, sort=True
555+
fil=self._visit_filter, rec=self._recurse, bf=True, sort=True
566556
):
567557
dirpath = path.dirpath()
568558
if dirpath not in seen_dirs:
@@ -636,6 +626,18 @@ def _recurse(self, dirpath):
636626
ihook.pytest_collect_directory(path=dirpath, parent=self)
637627
return True
638628

629+
if six.PY2:
630+
631+
@staticmethod
632+
def _visit_filter(f):
633+
return f.check(file=1) and not f.strpath.endswith("*.pyc")
634+
635+
else:
636+
637+
@staticmethod
638+
def _visit_filter(f):
639+
return f.check(file=1)
640+
639641
def _tryconvertpyarg(self, x):
640642
"""Convert a dotted module name to path."""
641643
try:

0 commit comments

Comments
 (0)