From 33eeda0339b84e555efc23f6cb334eeef55975e1 Mon Sep 17 00:00:00 2001 From: TanyaAgarwal28 <8979149361t@gmail.com> Date: Wed, 11 Oct 2023 14:37:29 +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 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/testing/test_conftest.py b/testing/test_conftest.py index 0b671c6bf..f54ba2312 100644 --- a/testing/test_conftest.py +++ b/testing/test_conftest.py @@ -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