88from  typing  import  Dict 
99from  typing  import  FrozenSet 
1010from  typing  import  List 
11+ from  typing  import  Tuple 
1112
1213import  attr 
1314import  py 
@@ -482,13 +483,13 @@ def _perform_collect(self, args, genitems):
482483        self .trace ("perform_collect" , self , args )
483484        self .trace .root .indent  +=  1 
484485        self ._notfound  =  []
485-         initialpaths  =  []
486-         self ._initialparts  =  []
486+         initialpaths  =  []   # type: List[py.path.local] 
487+         self ._initialparts  =  []   # type: List[Tuple[py.path.local, List[str]]] 
487488        self .items  =  items  =  []
488489        for  arg  in  args :
489-             parts  =  self ._parsearg (arg )
490-             self ._initialparts .append (parts )
491-             initialpaths .append (parts [ 0 ] )
490+             fspath ,  parts  =  self ._parsearg (arg )
491+             self ._initialparts .append (( fspath ,  parts ) )
492+             initialpaths .append (fspath )
492493        self ._initialpaths  =  frozenset (initialpaths )
493494        rep  =  collect_one_node (self )
494495        self .ihook .pytest_collectreport (report = rep )
@@ -508,25 +509,22 @@ def _perform_collect(self, args, genitems):
508509            return  items 
509510
510511    def  collect (self ):
511-         for  initialpart  in  self ._initialparts :
512-             self .trace ("processing argument" , initialpart )
512+         for  fspath ,  parts  in  self ._initialparts :
513+             self .trace ("processing argument" , ( fspath ,  parts ) )
513514            self .trace .root .indent  +=  1 
514515            try :
515-                 yield  from  self ._collect (initialpart )
516+                 yield  from  self ._collect (fspath ,  parts )
516517            except  NoMatch :
517-                 report_arg  =  "::" .join (map (str ,  initialpart ))
518+                 report_arg  =  "::" .join ((str ( fspath ),  * parts ))
518519                # we are inside a make_report hook so 
519520                # we cannot directly pass through the exception 
520521                self ._notfound .append ((report_arg , sys .exc_info ()[1 ]))
521522
522523            self .trace .root .indent  -=  1 
523524
524-     def  _collect (self , arg ):
525+     def  _collect (self , argpath ,  names ):
525526        from  _pytest .python  import  Package 
526527
527-         names  =  arg [:]
528-         argpath  =  names .pop (0 )
529- 
530528        # Start with a Session root, and delve to argpath item (dir or file) 
531529        # and stack all Packages found on the way. 
532530        # No point in finding packages when collecting doctests 
@@ -550,7 +548,7 @@ def _collect(self, arg):
550548        # If it's a directory argument, recurse and look for any Subpackages. 
551549        # Let the Package collector deal with subnodes, don't collect here. 
552550        if  argpath .check (dir = 1 ):
553-             assert  not  names , "invalid arg {!r}" .format (arg )
551+             assert  not  names , "invalid arg {!r}" .format (( argpath ,  names ) )
554552
555553            seen_dirs  =  set ()
556554            for  path  in  argpath .visit (
@@ -660,19 +658,19 @@ def _tryconvertpyarg(self, x):
660658
661659    def  _parsearg (self , arg ):
662660        """ return (fspath, names) tuple after checking the file exists. """ 
663-         parts  =  str (arg ).split ("::" )
661+         strpath ,  * parts  =  str (arg ).split ("::" )
664662        if  self .config .option .pyargs :
665-             parts [ 0 ]  =  self ._tryconvertpyarg (parts [ 0 ] )
666-         relpath  =  parts [ 0 ] .replace ("/" , os .sep )
667-         path  =  self .config .invocation_dir .join (relpath , abs = True )
668-         if  not  path .check ():
663+             strpath  =  self ._tryconvertpyarg (strpath )
664+         relpath  =  strpath .replace ("/" , os .sep )
665+         fspath  =  self .config .invocation_dir .join (relpath , abs = True )
666+         if  not  fspath .check ():
669667            if  self .config .option .pyargs :
670668                raise  UsageError (
671669                    "file or package not found: "  +  arg  +  " (missing __init__.py?)" 
672670                )
673671            raise  UsageError ("file not found: "  +  arg )
674-         parts [ 0 ]  =  path .realpath ()
675-         return  parts 
672+         fspath  =  fspath .realpath ()
673+         return  ( fspath ,  parts ) 
676674
677675    def  matchnodes (self , matching , names ):
678676        self .trace ("matchnodes" , matching , names )
0 commit comments