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