(
self,
pytester: Pytester,
ini_file_text,
invalid_keys,
warning_output,
exception_text,
)
| 246 | ) |
| 247 | @pytest.mark.filterwarnings("default") |
| 248 | def test_invalid_config_options( |
| 249 | self, |
| 250 | pytester: Pytester, |
| 251 | ini_file_text, |
| 252 | invalid_keys, |
| 253 | warning_output, |
| 254 | exception_text, |
| 255 | ) -> None: |
| 256 | pytester.makeconftest( |
| 257 | """ |
| 258 | def pytest_addoption(parser): |
| 259 | parser.addini("conftest_ini_key", "") |
| 260 | """ |
| 261 | ) |
| 262 | pytester.makepyfile("def test(): pass") |
| 263 | pytester.makeini(ini_file_text) |
| 264 | |
| 265 | config = pytester.parseconfig() |
| 266 | assert sorted(config._get_unknown_ini_keys()) == sorted(invalid_keys) |
| 267 | |
| 268 | result = pytester.runpytest() |
| 269 | result.stdout.fnmatch_lines(warning_output) |
| 270 | |
| 271 | result = pytester.runpytest("--strict-config") |
| 272 | if exception_text: |
| 273 | result.stderr.fnmatch_lines("ERROR: " + exception_text) |
| 274 | assert result.ret == pytest.ExitCode.USAGE_ERROR |
| 275 | else: |
| 276 | result.stderr.no_fnmatch_line(exception_text) |
| 277 | assert result.ret == pytest.ExitCode.OK |
| 278 | |
| 279 | @pytest.mark.filterwarnings("default") |
| 280 | def test_silence_unknown_key_warning(self, pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected