{"id":"0de2bd5c1e8154f5","repo":"pytest-dev/pytest","slug":"could-not-find-test-report-matching-inamepart-r","errorCode":null,"errorMessage":"could not find test report matching {inamepart!r}: no test reports at all!","messagePattern":"could not find test report matching (.+?): no test reports at all!","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/_pytest/pytester.py","lineNumber":374,"sourceCode":"        inamepart: str = \"\",\n        names: str | Iterable[str] = (\n            \"pytest_runtest_logreport\",\n            \"pytest_collectreport\",\n        ),\n        when: str | None = None,\n    ) -> CollectReport | TestReport:\n        \"\"\"Return a testreport whose dotted import path matches.\"\"\"\n        values = []\n        for rep in self.getreports(names=names):\n            if not when and rep.when != \"call\" and rep.passed:\n                # setup/teardown passing reports - let's ignore those\n                continue\n            if when and rep.when != when:\n                continue\n            if not inamepart or inamepart in rep.nodeid.split(\"::\"):\n                values.append(rep)\n        if not values:\n            raise ValueError(\n                f\"could not find test report matching {inamepart!r}: \"\n                \"no test reports at all!\"\n            )\n        if len(values) > 1:\n            raise ValueError(\n                f\"found 2 or more testreports matching {inamepart!r}: {values}\"\n            )\n        return values[0]\n\n    @overload\n    def getfailures(\n        self,\n        names: Literal[\"pytest_collectreport\"],\n    ) -> Sequence[CollectReport]: ...\n\n    @overload\n    def getfailures(\n        self,","sourceCodeStart":356,"sourceCodeEnd":392,"githubUrl":"https://github.com/pytest-dev/pytest/blob/98b357f69e380da908740a212288d73b2ee06687/src/_pytest/pytester.py#L356-L392","documentation":"Raised by Pytester.matchreport when it iterates over collected pytest reports and finds zero that match the given inamepart substring of a node id. The message explicitly notes 'no test reports at all!', meaning the run produced no collect/test reports to match against. This is a pytester-internal helper used in tests that assert on report outcomes.","triggerScenarios":"Calling result.matchreport('test_foo') on a RunResult/LineMatcher whose underlying pytest run collected nothing, failed at collection, or whose reports were never recorded (e.g. runpytest was never invoked, or the run crashed before reporting).","commonSituations":"Forgetting to call runpytest_inprocess/subprocess before asserting on reports; a typo in the test name passed to matchreport; the spawned pytest subprocess errored out at import time before any test ran; a conftest.py sys.excepthook or collection error swallowed reporting.","solutions":["Ensure runpytest(...) (or runpytest_inprocess/runpytest_subprocess) is actually called and its result stored before calling matchreport.","Inspect reprec.getreports() / the captured output to confirm the run collected tests and produced reports.","Fix the underlying collection/import error so the spawned run emits reports.","Pass the correct inamepart matching the test's node id, or pass '' to match any report."],"exampleFix":"// before\nreprec = pytester.runpytest_inprocess()\nrep = reprec.matchreport(\"test_bar\")  # name typo, or no run at all\n// after\nreprec = pytester.runpytest_inprocess()\nassert reprec.getreports()  # sanity check reports exist\nrep = reprec.matchreport(\"test_foo\")","handlingStrategy":"validation","validationCode":"reports = reprec.getreports()\nif not reports:\n    raise AssertionError(\"pytest run produced no reports; check collection errors first\")\nrep = reprec.matchreport(\"test_foo\")","typeGuard":null,"tryCatchPattern":"try:\n    rep = reprec.matchreport(\"test_foo\")\nexcept ValueError as e:\n    print(reprec.stdout.str())  # debug the actual run output\n    raise","preventionTips":["Always call runpytest and store the result before asserting on reports.","Sanity-check reprec.getreports() is non-empty.","Verify the spawned pytest collected the expected tests via stdout."],"tags":["pytester","test-reports","assertion"],"analyzedSha":"98b357f69e380da908740a212288d73b2ee06687","analyzedAt":"2026-08-04T20:26:34.442Z","schemaVersion":2}