@@ -402,10 +402,6 @@ def __getattr__(self, name: str):
402
402
return x
403
403
404
404
405
- class NoMatch (Exception ):
406
- """Matching cannot locate matching names."""
407
-
408
-
409
405
class Interrupted (KeyboardInterrupt ):
410
406
"""Signals that the test run was interrupted."""
411
407
@@ -598,7 +594,7 @@ def perform_collect( # noqa: F811
598
594
self .trace ("perform_collect" , self , args )
599
595
self .trace .root .indent += 1
600
596
601
- self ._notfound = [] # type: List[Tuple[str, NoMatch ]]
597
+ self ._notfound = [] # type: List[Tuple[str, Sequence[nodes.Collector] ]]
602
598
self ._initial_parts = [] # type: List[Tuple[py.path.local, List[str]]]
603
599
self .items = [] # type: List[nodes.Item]
604
600
@@ -619,8 +615,8 @@ def perform_collect( # noqa: F811
619
615
self .trace .root .indent -= 1
620
616
if self ._notfound :
621
617
errors = []
622
- for arg , exc in self ._notfound :
623
- line = "(no name {!r} in any of {!r})" .format (arg , exc . args [ 0 ] )
618
+ for arg , cols in self ._notfound :
619
+ line = "(no name {!r} in any of {!r})" .format (arg , cols )
624
620
errors .append ("not found: {}\n {}" .format (arg , line ))
625
621
raise UsageError (* errors )
626
622
if not genitems :
@@ -644,14 +640,7 @@ def collect(self) -> Iterator[Union[nodes.Item, nodes.Collector]]:
644
640
for fspath , parts in self ._initial_parts :
645
641
self .trace ("processing argument" , (fspath , parts ))
646
642
self .trace .root .indent += 1
647
- try :
648
- yield from self ._collect (fspath , parts )
649
- except NoMatch as exc :
650
- report_arg = "::" .join ((str (fspath ), * parts ))
651
- # we are inside a make_report hook so
652
- # we cannot directly pass through the exception
653
- self ._notfound .append ((report_arg , exc ))
654
-
643
+ yield from self ._collect (fspath , parts )
655
644
self .trace .root .indent -= 1
656
645
self ._collection_node_cache1 .clear ()
657
646
self ._collection_node_cache2 .clear ()
@@ -727,7 +716,10 @@ def _collect(
727
716
self ._collection_node_cache1 [argpath ] = col
728
717
m = self .matchnodes (col , names )
729
718
if not m :
730
- raise NoMatch (col )
719
+ report_arg = "::" .join ((str (argpath ), * names ))
720
+ self ._notfound .append ((report_arg , col ))
721
+ return
722
+
731
723
# If __init__.py was the only file requested, then the matched node will be
732
724
# the corresponding Package, and the first yielded item will be the __init__
733
725
# Module itself, so just use that. If this special case isn't taken, then all
0 commit comments