MCPcopy
hub / github.com/pytest-dev/pytest / test_addini

Method test_addini

testing/test_config.py:843–865  ·  view source on GitHub ↗
(self, pytester: Pytester, maybe_type: str)

Source from the content-addressed store, hash-verified

841
842 @pytest.mark.parametrize("maybe_type", ["not passed", "None", '"string"'])
843 def test_addini(self, pytester: Pytester, maybe_type: str) -> None:
844 if maybe_type == "not passed":
845 type_string = ""
846 else:
847 type_string = f", {maybe_type}"
848
849 pytester.makeconftest(
850 f"""
851 def pytest_addoption(parser):
852 parser.addini("myname", "my new ini value"{type_string})
853 """
854 )
855 pytester.makeini(
856 """
857 [pytest]
858 myname=hello
859 """
860 )
861 config = pytester.parseconfig()
862 val = config.getini("myname")
863 assert val == "hello"
864 with pytest.raises(ValueError):
865 config.getini("other")
866
867 @pytest.mark.parametrize("config_type", ["ini", "pyproject"])
868 def test_addini_paths(self, pytester: Pytester, config_type: str) -> None:

Callers

nothing calls this directly

Calls 4

makeconftestMethod · 0.45
makeiniMethod · 0.45
parseconfigMethod · 0.45
getiniMethod · 0.45

Tested by

no test coverage detected