From af8162b90eee8fc9cdfc9dacf452e66d9ca9661b Mon Sep 17 00:00:00 2001 From: TanyaAgarwal28 <8979149361t@gmail.com> Date: Wed, 11 Oct 2023 13:04:40 +0530 Subject: [PATCH] Bug Fix 11282: config.getini returns an empty list for an option of type string absent in INI file --- testing/test_conftest.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/testing/test_conftest.py b/testing/test_conftest.py index ca97b2611..0b671c6bf 100644 --- a/testing/test_conftest.py +++ b/testing/test_conftest.py @@ -224,23 +224,23 @@ def test_setinitial_conftest_subdirs(pytester: Pytester, name: str) -> None: def test_my_option(pytester: Pytester): testdir = pytester.mkdir("test_my_option") conftest_content = """ - import pytest - def pytest_addoption(parser): - parser.addini( - "my_option", - type="string", - default=None, - help="My option", - ) - @pytest.fixture(scope='session') - def my_option(request): - return request.config.getini("my_option") + import pytest + def pytest_addoption(parser): + parser.addini( + "my_option", + type="string", + default=None, + help="My option", + ) + @pytest.fixture(scope='session') + def my_option(request): + return request.config.getini("my_option") """ testdir.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 + 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))