{"id":"dfef492135b9894f","repo":"pytest-dev/pytest","slug":"no-option-named-name-r","errorCode":null,"errorMessage":"no option named {name!r}","messagePattern":"no option named (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/_pytest/config/__init__.py","lineNumber":2070,"sourceCode":"        :param default: Fallback value if no option of that name is **declared** via :hook:`pytest_addoption`.\n            Note this parameter will be ignored when the option is **declared** even if the option's value is ``None``.\n        :param skip: If ``True``, raise :func:`pytest.skip` if option is undeclared or has a ``None`` value.\n            Note that even if ``True``, if a default was specified it will be returned instead of a skip.\n        \"\"\"\n        name = self._parser._opt2dest.get(name, name)\n        try:\n            val = getattr(self.option, name)\n            if val is None and skip:\n                raise AttributeError(name)\n            return val\n        except AttributeError as e:\n            if default is not NOTSET:\n                return default\n            if skip:\n                import pytest\n\n                pytest.skip(f\"no {name!r} option found\")\n            raise ValueError(f\"no option named {name!r}\") from e\n\n    def getvalue(self, name: str, path=None):\n        \"\"\"Deprecated, use getoption() instead.\"\"\"\n        return self.getoption(name)\n\n    def getvalueorskip(self, name: str, path=None):\n        \"\"\"Deprecated, use getoption(skip=True) instead.\"\"\"\n        return self.getoption(name, skip=True)\n\n    #: Verbosity type for failed assertions (see :confval:`verbosity_assertions`).\n    VERBOSITY_ASSERTIONS: Final = \"assertions\"\n    #: Verbosity type for test case execution (see :confval:`verbosity_test_cases`).\n    VERBOSITY_TEST_CASES: Final = \"test_cases\"\n    #: Verbosity type for failed subtests (see :confval:`verbosity_subtests`).\n    VERBOSITY_SUBTESTS: Final = \"subtests\"\n\n    _VERBOSITY_INI_DEFAULT: Final = \"auto\"\n","sourceCodeStart":2052,"sourceCodeEnd":2088,"githubUrl":"https://github.com/pytest-dev/pytest/blob/98b357f69e380da908740a212288d73b2ee06687/src/_pytest/config/__init__.py#L2052-L2088","documentation":"Raised by Config.getoption (config/__init__.py:2058-2070) when the requested command-line option dest is neither present on the option object nor registered (no matching pytest_addoption), AND no default was supplied AND skip=False. The lookup against self.option raises AttributeError, which is converted to ValueError.","triggerScenarios":"Calling config.getoption('my_opt') without a default for an option that no plugin declared via pytest_addoption. Also reachable via the deprecated getvalue(). With skip=True the call would pytest.skip instead.","commonSituations":"Typo in the option dest; querying an option from a plugin that is not installed/loaded; version upgrades removing/renaming options; forgetting that getoption takes the dest name (or --flag form), not an arbitrary string.","solutions":["Pass a default: config.getoption('my_opt', default=None) so missing options don't raise.","Register the option in a conftest pytest_addoption hook (parser.addoption('--my-opt', dest='my_opt')).","Fix spelling/casing of the dest name (or use the --flag form).","Use skip=True if a missing option should skip the test rather than error."],"exampleFix":"# before\nval = config.getoption('my_opt')   # not declared\n\n# after\nval = config.getoption('my_opt', default=False)","handlingStrategy":"validation","validationCode":"def safe_getoption(config, name, default=None):\n    return config.getoption(name, default=default)","typeGuard":"def option_exists(config, name: str) -> bool:\n    dest = config._parser._opt2dest.get(name, name)\n    return hasattr(config.option, dest)","tryCatchPattern":"try:\n    val = config.getoption(name)\nexcept ValueError:\n    val = None  # option not declared; degrade gracefully","preventionTips":["Always pass a default to getoption for optional features.","Register options in pytest_addoption before reading them.","Use skip=True when a missing option should skip rather than fail."],"tags":["config","getoption","cli-option","pytest"],"analyzedSha":"98b357f69e380da908740a212288d73b2ee06687","analyzedAt":"2026-08-04T20:26:34.442Z","schemaVersion":2}