{"record":{"id":"5e2f9947536be9eb","repo":"pytest-dev/pytest","slug":"o-override-ini-expects-option-value-style-got","errorCode":null,"errorMessage":"-o/--override-ini expects option=value style (got: {ini_config!r}).","messagePattern":"-o/--override-ini expects option=value style \\(got: (.+?)\\)\\.","errorType":"validation","errorClass":"UsageError","httpStatus":null,"severity":"error","filePath":"src/_pytest/config/findpaths.py","lineNumber":390,"sourceCode":"\n    return [get_dir_from_path(path) for path in possible_paths if safe_exists(path)]\n\n\ndef parse_override_ini(override_ini: Sequence[str] | None) -> ConfigDict:\n    \"\"\"Parse the -o/--override-ini command line arguments and return the overrides.\n\n    :raises UsageError:\n        If one of the values is malformed.\n    \"\"\"\n    overrides = {}\n    # override_ini is a list of \"ini=value\" options.\n    # Always use the last item if multiple values are set for same ini-name,\n    # e.g. -o foo=bar1 -o foo=bar2 will set foo to bar2.\n    for ini_config in override_ini or ():\n        try:\n            key, user_ini_value = ini_config.split(\"=\", 1)\n        except ValueError as e:\n            raise UsageError(\n                f\"-o/--override-ini expects option=value style (got: {ini_config!r}).\"\n            ) from e\n        else:\n            overrides[key] = ConfigValue(user_ini_value, origin=\"override\", mode=\"ini\")\n    return overrides\n\n\nCFG_PYTEST_SECTION = \"[pytest] section in {filename} files is no longer supported, change to [tool:pytest] instead.\"\n\n\ndef determine_setup(\n    *,\n    inifile: str | None,\n    override_ini: Sequence[str] | None,\n    args: Sequence[str],\n    rootdir_cmd_arg: str | None,\n    invocation_dir: Path,\n) -> tuple[Path, Path | None, ConfigDict, Sequence[str]]:","sourceCodeStart":372,"sourceCodeEnd":408,"githubUrl":"https://github.com/pytest-dev/pytest/blob/0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc/src/_pytest/config/findpaths.py#L372-L408","documentation":"The -o/--override-ini command-line flag takes one or more key=value pairs that override ini options at runtime. pytest splits each argument on the first '='. If the argument has no '=' (so .split('=',1) returns a single-element list and unpacking two values fails with ValueError), pytest re-raises as UsageError with the offending argument quoted.","triggerScenarios":"Calling pytest -o addopts (missing =value); pytest -o =value (empty key); pytest -o 'addopts =-ra' where shell or quoting stripped the '='; passing a flag-style '-o verbose' instead of 'verbose=true'.","commonSituations":"Shell quoting mistakes; forgetting the value half of the override; copy-pasting an ini-style line that lacks '='.","solutions":["Supply the override as key=value, e.g. pytest -o addopts=-ra.","For multiple overrides, repeat -o for each: pytest -o foo=1 -o bar=2.","Quote the whole pair if it contains shell metacharacters: pytest -o 'addopts=-ra -q'."],"exampleFix":"// before\npytest -o addopts tests/\n// after\npytest -o addopts=-ra tests/","handlingStrategy":"validation","validationCode":"def is_valid_override(arg: str) -> bool:\n    return '=' in arg and arg.split('=', 1)[0].strip() != ''\n\noverrides = ['addopts', 'addopts=-ra']\nfor o in overrides:\n    assert is_valid_override(o), f'bad -o value: {o!r}'","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Always form -o overrides as key=value with a non-empty key.","Quote overrides that contain spaces to survive the shell."],"tags":["cli","config","override-ini"],"backgroundTag":null,"analyzedSha":"0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc","analyzedAt":"2026-08-11T20:52:36.969Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}