{"record":{"id":"c8d251cb9d51b659","repo":"pytest-dev/pytest","slug":"you-must-specify-at-least-one-parameter-to-match-o","errorCode":null,"errorMessage":"You must specify at least one parameter to match on.","messagePattern":"You must specify at least one parameter to match on\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/_pytest/raises.py","lineNumber":622,"sourceCode":"        self,\n        expected_exception: (\n            type[BaseExcT_co_default] | tuple[type[BaseExcT_co_default], ...] | None\n        ) = None,\n        /,\n        *,\n        match: str | Pattern[str] | None = None,\n        check: Callable[[BaseExcT_co_default], bool] | None = None,\n    ):\n        super().__init__(match=match, check=check)\n        if isinstance(expected_exception, tuple):\n            expected_exceptions = expected_exception\n        elif expected_exception is None:\n            expected_exceptions = ()\n        else:\n            expected_exceptions = (expected_exception,)\n\n        if (expected_exceptions == ()) and match is None and check is None:\n            raise ValueError(\"You must specify at least one parameter to match on.\")\n\n        self.expected_exceptions = tuple(\n            self._parse_exc(e, expected=\"a BaseException type\")\n            for e in expected_exceptions\n        )\n\n        self._just_propagate = False\n\n    def matches(\n        self,\n        exception: BaseException | None,\n    ) -> TypeGuard[BaseExcT_co_default]:\n        \"\"\"Check if an exception matches the requirements of this :class:`RaisesExc`.\n        If it fails, :attr:`RaisesExc.fail_reason` will be set.\n\n        Examples::\n\n            assert RaisesExc(ValueError).matches(my_exception):","sourceCodeStart":604,"sourceCodeEnd":640,"githubUrl":"https://github.com/pytest-dev/pytest/blob/0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc/src/_pytest/raises.py#L604-L640","documentation":"Raised by RaisesExc.__init__ when none of expected_exception, match, or check is supplied. RaisesExc needs at least one matching criterion to be meaningful; an empty matcher would match any exception and is almost always a bug. The guard runs after tuple/None normalization, so RaisesExc() with all defaults triggers it.","triggerScenarios":"Constructing RaisesExc() with no arguments; RaisesExc(None); or RaisesExc(()) where match and check are also None. The check is `(expected_exceptions == ()) and match is None and check is None`.","commonSituations":"Building RaisesExc objects programmatically (e.g. in a fixture or helper) and forgetting to forward a parameter; refactor that drops the exception type while leaving match/check unset; conditional construction that leaves all three empty on a branch.","solutions":["Supply at least one argument: the exception type, a match regex, or a check callable.","In helper code, default the missing parameter explicitly (e.g. expected_exception=ValueError) rather than leaving it None.","If you intend 'match anything', use RaisesExc(BaseException) to make that intent explicit."],"exampleFix":"// before\nmatcher = RaisesExc()  # ValueError\n// after\nmatcher = RaisesExc(ValueError)\n// or express intent explicitly:\nmatcher = RaisesExc(BaseException)","handlingStrategy":"validation","validationCode":"assert expected_exception is not None or match is not None or check is not None, 'RaisesExc needs an exception, match, or check'","typeGuard":"def raisesexc_has_criterion(expected_exception, match, check) -> bool:\n    return expected_exception is not None or match is not None or check is not None","tryCatchPattern":null,"preventionTips":["Always supply at least one of expected_exception, match, or check when building RaisesExc.","In helpers that forward parameters, default expected_exception to a sensible type rather than None.","Document RaisesExc construction at the call site."],"tags":["pytest","raises","raisesexc","validation","misuse"],"backgroundTag":null,"analyzedSha":"0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc","analyzedAt":"2026-08-11T20:52:36.969Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}