{"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/98b357f69e380da908740a212288d73b2ee06687/src/_pytest/raises.py#L604-L640","documentation":"Raised by RaisesExc when none of expected_exception, match, or check is provided. At least one of these is required to define what the matcher should look for.","triggerScenarios":"Constructing RaisesExc() with no arguments, or pytest.raises() in context-manager form with nothing. Hits raises.py:622.","commonSituations":"Programmatically building a RaisesExc and forgetting to set any constraint; a default-argument path that passes nothing; copy-paste of a partial template.","solutions":["Pass an exception type as the first argument.","Or pass match='...' to match on the message only.","Or pass check=lambda e: ... to define a custom matching predicate."],"exampleFix":"// before\nRaisesExc()\n// after\nRaisesExc(ValueError)","handlingStrategy":"validation","validationCode":"if expected_exception is None and match is None and check is None:\n    raise ValueError('provide at least one of: expected_exception, match, check')\nRaisesExc(expected_exception, match=match, check=check)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always supply at least one constraint when constructing RaisesExc.","When building matchers programmatically, default at least one parameter.","Use pytest.raises(Exc) shorthand which always sets expected_exception."],"tags":["pytest","raises","validation"],"analyzedSha":"98b357f69e380da908740a212288d73b2ee06687","analyzedAt":"2026-08-04T20:26:34.442Z","schemaVersion":2}