{"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":"exception","errorClass":"UsageError","httpStatus":null,"severity":"error","filePath":"src/_pytest/config/findpaths.py","lineNumber":275,"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":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/pytest-dev/pytest/blob/98b357f69e380da908740a212288d73b2ee06687/src/_pytest/config/findpaths.py#L257-L293","documentation":"Raised when a -o/--override-ini command-line argument does not contain an '=' sign separating the option name from its value. pytest splits each override on the first '='; a missing '=' causes str.split('=', 1) to yield a single element, triggering ValueError and this UsageError.","triggerScenarios":"Running pytest -o foo (no value), pytest -o 'justakey', or pytest --override-ini 'verbose' without '=true'. The split at line 273 returns a list of length 1, ValueError is raised and caught at 274-277.","commonSituations":"Forgetting the '=value' portion of an override; passing a flag-style option name expecting boolean toggling; shell quoting issues that strip the '='; typos in scripted pytest invocations.","solutions":["Always use the form -o name=value, e.g. -o addopts='-v' or -o verbose=true.","For booleans use explicit values: -o verbose=true / verbose=false.","Quote the whole override in the shell if the value contains spaces: -o 'addopts=-v -ra'."],"exampleFix":"# before\npytest -o verbose\n\n# after\npytest -o verbose=true","handlingStrategy":"validation","validationCode":"def validate_override(arg: str) -> tuple[str, str]:\n    if '=' not in arg:\n        raise ValueError(f'-o/--override-ini expects option=value style (got: {arg!r})')\n    key, value = arg.split('=', 1)\n    if not key:\n        raise ValueError(f'empty option name in override {arg!r}')\n    return key, value","typeGuard":"def is_valid_override(arg: str) -> bool:\n    return '=' in arg and arg.split('=', 1)[0] != ''","tryCatchPattern":null,"preventionTips":["Always use the -o name=value form.","Quote overrides containing spaces or special shell characters.","For booleans, pass explicit true/false values."],"tags":["pytest","config","cli","override-ini","usage-error"],"analyzedSha":"98b357f69e380da908740a212288d73b2ee06687","analyzedAt":"2026-08-04T20:26:34.442Z","schemaVersion":2}