diff options
author | Gleb Nikonorov <gleb.i.nikonorov@gmail.com> | 2020-06-18 11:58:41 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-18 12:58:41 -0300 |
commit | 4cc4ebf3c9f79eb9d7484c763b11dea3ddff4b82 (patch) | |
tree | c0be4bccea22dba2c6d2b7ef3c145414ff4d0070 /testing/test_config.py | |
parent | 88a187aae884fd7c56e2c619ac3b1f1d4fc8bb5c (diff) | |
download | pytest-4cc4ebf3c9f79eb9d7484c763b11dea3ddff4b82.tar.gz |
Don't treat ini keys defined in conftest.py as invalid (#7384)
Diffstat (limited to 'testing/test_config.py')
-rw-r--r-- | testing/test_config.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/testing/test_config.py b/testing/test_config.py index d59d641f6..c9eea7a16 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -208,21 +208,39 @@ class TestParseIni: [], "", ), + ( + """ + [pytest] + conftest_ini_key = 1 + """, + [], + [], + "", + ), ], ) def test_invalid_ini_keys( self, testdir, ini_file_text, invalid_keys, stderr_output, exception_text ): + testdir.makeconftest( + """ + def pytest_addoption(parser): + parser.addini("conftest_ini_key", "") + """ + ) testdir.tmpdir.join("pytest.ini").write(textwrap.dedent(ini_file_text)) + config = testdir.parseconfig() assert sorted(config._get_unknown_ini_keys()) == sorted(invalid_keys) result = testdir.runpytest() result.stderr.fnmatch_lines(stderr_output) - if stderr_output: + if exception_text: with pytest.raises(pytest.fail.Exception, match=exception_text): testdir.runpytest("--strict-config") + else: + testdir.runpytest("--strict-config") @pytest.mark.parametrize( "ini_file_text, exception_text", |