Bug Fix 11282: config.getini returns an empty list for an option of type string absent in INI file
This commit is contained in:
parent
cfa662e493
commit
2bb9e30e08
|
@ -222,10 +222,9 @@ def test_setinitial_conftest_subdirs(pytester: Pytester, name: str) -> None:
|
||||||
|
|
||||||
|
|
||||||
def test_my_option(pytester: Pytester):
|
def test_my_option(pytester: Pytester):
|
||||||
testdir = pytester.mkdir("test_my_option")
|
pytester.makeconftest(
|
||||||
conftest_content = """\
|
"""\
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
||||||
parser.addini(
|
parser.addini(
|
||||||
"my_option",
|
"my_option",
|
||||||
|
@ -237,25 +236,16 @@ def test_my_option(pytester: Pytester):
|
||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session')
|
||||||
def my_option(request):
|
def my_option(request):
|
||||||
return request.config.getini("my_option")
|
return request.config.getini("my_option")
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# Place conftest.py in the root directory of the project
|
|
||||||
testdir.parent.joinpath("conftest.py").write_text(
|
|
||||||
conftest_content, encoding="utf-8"
|
|
||||||
)
|
)
|
||||||
|
pytester.makepyfile(
|
||||||
# Create a simple test function
|
"""\
|
||||||
test_content = """\
|
def test_x(my_option):
|
||||||
|
|
||||||
def test_example(my_option):
|
|
||||||
assert my_option is None
|
assert my_option is None
|
||||||
|
|
||||||
"""
|
"""
|
||||||
testdir.joinpath("test_my_option.py").write_text(test_content, encoding="utf-8")
|
)
|
||||||
result = pytester.runpytest(
|
res = pytester.runpytest()
|
||||||
str(testdir.parent)
|
assert res.ret == 0
|
||||||
) # Run pytest from the root directory
|
|
||||||
assert result.ret == 0
|
|
||||||
|
|
||||||
|
|
||||||
def test_conftest_confcutdir(pytester: Pytester) -> None:
|
def test_conftest_confcutdir(pytester: Pytester) -> None:
|
||||||
|
|
Loading…
Reference in New Issue