MCPcopy Create free account
hub / github.com/pytest-dev/pytest / matchreport

Method matchreport

src/_pytest/pytester.py:351–381  ·  view source on GitHub ↗

Return a testreport whose dotted import path matches.

(
        self,
        inamepart: str = "",
        names: Union[str, Iterable[str]] = (
            "pytest_runtest_logreport",
            "pytest_collectreport",
        ),
        when: Optional[str] = None,
    )

Source from the content-addressed store, hash-verified

349 return [x.report for x in self.getcalls(names)]
350
351 def matchreport(
352 self,
353 inamepart: str = "",
354 names: Union[str, Iterable[str]] = (
355 "pytest_runtest_logreport",
356 "pytest_collectreport",
357 ),
358 when: Optional[str] = None,
359 ) -> Union[CollectReport, TestReport]:
360 """Return a testreport whose dotted import path matches."""
361 values = []
362 for rep in self.getreports(names=names):
363 if not when and rep.when != "call" and rep.passed:
364 # setup/teardown passing reports - let's ignore those
365 continue
366 if when and rep.when != when:
367 continue
368 if not inamepart or inamepart in rep.nodeid.split("::"):
369 values.append(rep)
370 if not values:
371 raise ValueError(
372 "could not find test report matching %r: "
373 "no test reports at all!" % (inamepart,)
374 )
375 if len(values) > 1:
376 raise ValueError(
377 "found 2 or more testreports matching {!r}: {}".format(
378 inamepart, values
379 )
380 )
381 return values[0]
382
383 @overload
384 def getfailures(

Callers 4

test_simple_unittestFunction · 0.80
test_setupFunction · 0.80

Calls 3

getreportsMethod · 0.95
appendMethod · 0.80
formatMethod · 0.45

Tested by

no test coverage detected