Parse the -o/--override-ini command line arguments and return the overrides. :raises UsageError: If one of the values is malformed.
(override_ini: Sequence[str] | None)
| 251 | |
| 252 | |
| 253 | def parse_override_ini(override_ini: Sequence[str] | None) -> ConfigDict: |
| 254 | """Parse the -o/--override-ini command line arguments and return the overrides. |
| 255 | |
| 256 | :raises UsageError: |
| 257 | If one of the values is malformed. |
| 258 | """ |
| 259 | overrides = {} |
| 260 | # override_ini is a list of "ini=value" options. |
| 261 | # Always use the last item if multiple values are set for same ini-name, |
| 262 | # e.g. -o foo=bar1 -o foo=bar2 will set foo to bar2. |
| 263 | for ini_config in override_ini or (): |
| 264 | try: |
| 265 | key, user_ini_value = ini_config.split("=", 1) |
| 266 | except ValueError as e: |
| 267 | raise UsageError( |
| 268 | f"-o/--override-ini expects option=value style (got: {ini_config!r})." |
| 269 | ) from e |
| 270 | else: |
| 271 | overrides[key] = ConfigValue(user_ini_value, origin="override", mode="ini") |
| 272 | return overrides |
| 273 | |
| 274 | |
| 275 | CFG_PYTEST_SECTION = "[pytest] section in {filename} files is no longer supported, change to [tool:pytest] instead." |
no test coverage detected