Update tests to cover explicit None and "string" as addini() types

This commit is contained in:
Kyle Altendorf 2020-10-07 17:56:54 -04:00
parent af3759a503
commit 76acb44330
2 changed files with 10 additions and 4 deletions

View File

@ -1402,7 +1402,7 @@ class Config:
elif type == "bool": elif type == "bool":
return _strtobool(str(value).strip()) return _strtobool(str(value).strip())
else: else:
assert type is None assert type in [None, "string"]
return value return value
def _getconftest_pathlist( def _getconftest_pathlist(

View File

@ -570,11 +570,17 @@ class TestConfigAPI:
assert pl[0] == tmpdir assert pl[0] == tmpdir
assert pl[1] == somepath assert pl[1] == somepath
def test_addini(self, testdir): @pytest.mark.parametrize("maybe_type", ["not passed", "None", '"string"'])
def test_addini(self, testdir, maybe_type):
if maybe_type == "not passed":
type_string = ""
else:
type_string = f", {maybe_type}"
testdir.makeconftest( testdir.makeconftest(
""" f"""
def pytest_addoption(parser): def pytest_addoption(parser):
parser.addini("myname", "my new ini value") parser.addini("myname", "my new ini value"{type_string})
""" """
) )
testdir.makeini( testdir.makeini(