{"record":{"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/0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc/src/_pytest/pytester.py#L356-L392","documentation":"Thrown by Pytester.RunResult.matchreport() when filtering captured pytest hook reports yields zero matches for the given inamepart/when filter. It means either no tests ran (no reports collected at all) or none matched the node-id fragment you passed. The 'no test reports at all!' wording specifically indicates the values list is empty.","triggerScenarios":"Calling pytester.matchreport('test_foo') after a pytester run where (a) collection failed so no TestReports exist, (b) the test name fragment doesn't appear as a '::'-delimited segment of any captured nodeid, or (c) the `when` filter excludes all reports (e.g. when='call' but only setup reports exist).","commonSituations":"Writing pytester-based plugin tests; typos in the test function name passed to matchreport; expecting a 'call' phase report when the test errored during setup; calling matchreport before runpytest_inprocess populated the HookRecorder.","solutions":["Inspect pytester.runpytest().parseoutcomes() to confirm tests actually ran and collected.","Verify the inamepart string is an exact '::'-delimited segment of the test's nodeid (e.g. 'test_foo', not 'foo').","Remove or correct the `when` argument if you only have setup/teardown reports.","Use matchreport with no inamepart to get the single report when only one test exists."],"exampleFix":"// before\nrep = reprec.matchreport(\"test_foo\", when=\"call\")\n// after\nresult = pytester.runpytest(\"-q\")\nassert result.ret == 0\nreprec = result.reprec\nreports = reprec.getreports(\"pytest_runtest_logreport\")\nassert reports, \"no reports collected - did the test run?\"\nrep = reprec.matchreport(\"test_foo\")","handlingStrategy":"validation","validationCode":"reports = reprec.getreports(\"pytest_runtest_logreport\")\nif not reports:\n    pytest.fail(\"no test reports collected - did the test run?\")\nmatches = [r for r in reports if 'test_foo' in r.nodeid.split('::')]\nassert len(matches) == 1, f\"expected 1 match, got {len(matches)}\"\nrep = reprec.matchreport('test_foo')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Inspect getreports() before matchreport() to confirm reports exist.","Use full '::'-delimited nodeid segments, never substrings.","Avoid passing when= unless you know the phase."],"tags":["pytester","test-report","nodeid","validation"],"backgroundTag":null,"analyzedSha":"0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc","analyzedAt":"2026-08-11T20:52:36.969Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}