@@ -528,9 +528,19 @@ def _collect(self, arg):
528
528
if argpath .check (dir = 1 ):
529
529
assert not names , "invalid arg %r" % (arg ,)
530
530
531
+ if six .PY2 :
532
+
533
+ def filter_ (f ):
534
+ return f .check (file = 1 ) and not f .strpath .endswith ("*.pyc" )
535
+
536
+ else :
537
+
538
+ def filter_ (f ):
539
+ return f .check (file = 1 )
540
+
531
541
seen_dirs = set ()
532
542
for path in argpath .visit (
533
- fil = lambda x : x . check ( file = 1 ) , rec = self ._recurse , bf = True , sort = True
543
+ fil = filter_ , rec = self ._recurse , bf = True , sort = True
534
544
):
535
545
dirpath = path .dirpath ()
536
546
if dirpath not in seen_dirs :
@@ -568,18 +578,17 @@ def _collectfile(self, path):
568
578
return ()
569
579
return ihook .pytest_collect_file (path = path , parent = self )
570
580
571
- def _recurse (self , path ):
572
- dirpath = path .dirpath ()
581
+ def _recurse (self , dirpath ):
573
582
if dirpath .basename == "__pycache__" :
574
- return True
575
- ihook = self .gethookproxy (dirpath )
576
- if ihook .pytest_ignore_collect (path = path , config = self .config ):
583
+ return
584
+ ihook = self .gethookproxy (dirpath . dirpath () )
585
+ if ihook .pytest_ignore_collect (path = dirpath , config = self .config ):
577
586
return
578
587
for pat in self ._norecursepatterns :
579
- if path .check (fnmatch = pat ):
588
+ if dirpath .check (fnmatch = pat ):
580
589
return False
581
- ihook = self .gethookproxy (path )
582
- ihook .pytest_collect_directory (path = path , parent = self )
590
+ ihook = self .gethookproxy (dirpath )
591
+ ihook .pytest_collect_directory (path = dirpath , parent = self )
583
592
return True
584
593
585
594
def _tryconvertpyarg (self , x ):
0 commit comments