Skip to content

Commit 3b4fb75

Browse files
authored
tests for #11381
1 parent ba27f9e commit 3b4fb75

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

testing/test_config.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,50 @@ def pytest_addoption(parser):
848848
config = pytester.parseconfig()
849849
assert config.getini("strip") is bool_val
850850

851+
@pytest.mark.parametrize(
852+
"str_val, int_val", [("10", 10), ("no-ini", 0)]
853+
)
854+
def test_addini_int(
855+
self, pytester: Pytester, str_val: str, int_val: bool
856+
) -> None:
857+
pytester.makeconftest(
858+
"""
859+
def pytest_addoption(parser):
860+
parser.addini("ini_param", "", type="int", default=2)
861+
"""
862+
)
863+
if str_val != "no-ini":
864+
pytester.makeini(
865+
f"""
866+
[pytest]
867+
ini_param={str_val}
868+
"""
869+
)
870+
config = pytester.parseconfig()
871+
assert config.getini("ini_param") == int_val
872+
873+
@pytest.mark.parametrize(
874+
"str_val, float_val", [("10.5", 10.5), ("no-ini", 0.0)]
875+
)
876+
def test_addini_float(
877+
self, pytester: Pytester, str_val: str, float_val: bool
878+
) -> None:
879+
pytester.makeconftest(
880+
"""
881+
def pytest_addoption(parser):
882+
parser.addini("ini_param", "", type="float", default=2.2)
883+
"""
884+
)
885+
if str_val != "no-ini":
886+
pytester.makeini(
887+
f"""
888+
[pytest]
889+
ini_param={str_val}
890+
"""
891+
)
892+
config = pytester.parseconfig()
893+
assert config.getini("ini_param") == float_val
894+
851895
def test_addinivalue_line_existing(self, pytester: Pytester) -> None:
852896
pytester.makeconftest(
853897
"""

0 commit comments

Comments
 (0)