MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_invalid_config_options

Method test_invalid_config_options

testing/test_config.py:248–277  ·  view source on GitHub ↗
(
        self,
        pytester: Pytester,
        ini_file_text,
        invalid_keys,
        warning_output,
        exception_text,
    )

Source from the content-addressed store, hash-verified

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:

Callers

nothing calls this directly

Calls 8

_get_unknown_ini_keysMethod · 0.80
fnmatch_linesMethod · 0.80
no_fnmatch_lineMethod · 0.80
makeconftestMethod · 0.45
makepyfileMethod · 0.45
makeiniMethod · 0.45
parseconfigMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected