Bug Fix 11282: config.getini returns an empty list for an option of type string absent in INI file

This commit is contained in:
TanyaAgarwal28 2023-10-11 14:37:29 +05:30
parent af8162b90e
commit 33eeda0339
1 changed files with 8 additions and 2 deletions

View File

@ -236,14 +236,20 @@ def test_my_option(pytester: Pytester):
def my_option(request):
return request.config.getini("my_option")
"""
testdir.joinpath("conftest.py").write_text(conftest_content, encoding="utf-8")
# Place conftest.py in the root directory of the project
testdir.parent.joinpath("conftest.py").write_text(
conftest_content, encoding="utf-8"
)
# Create a simple test function
test_content = """
def test_example(my_option):
assert my_option is None
"""
testdir.joinpath("test_my_option.py").write_text(test_content, encoding="utf-8")
result = pytester.runpytest(str(testdir))
result = pytester.runpytest(
str(testdir.parent)
) # Run pytest from the root directory
assert result.ret == 0