@@ -135,15 +135,45 @@ def test_ini_names(self, pytester: Pytester, name, section) -> None:
135
135
assert config .getini ("minversion" ) == "3.36"
136
136
137
137
def test_pyproject_toml (self , pytester : Pytester ) -> None :
138
- pytester .makepyprojecttoml (
138
+ pyproject_toml = pytester .makepyprojecttoml (
139
139
"""
140
140
[tool.pytest.ini_options]
141
141
minversion = "1.0"
142
142
"""
143
143
)
144
144
config = pytester .parseconfig ()
145
+ assert config .inipath == pyproject_toml
145
146
assert config .getini ("minversion" ) == "1.0"
146
147
148
+ def test_empty_pyproject_toml (self , pytester : Pytester ) -> None :
149
+ """An empty pyproject.toml is considered as config if no other option is found."""
150
+ pyproject_toml = pytester .makepyprojecttoml ("" )
151
+ config = pytester .parseconfig ()
152
+ assert config .inipath == pyproject_toml
153
+
154
+ def test_empty_pyproject_toml_found_many (self , pytester : Pytester ) -> None :
155
+ """
156
+ In case we find multiple pyproject.toml files in our search, without a [tool.pytest.ini_options]
157
+ table and without finding other candidates, the closest to where we started wins.
158
+ """
159
+ pytester .makefile (
160
+ ".toml" ,
161
+ ** {
162
+ "pyproject" : "" ,
163
+ "foo/pyproject" : "" ,
164
+ "foo/bar/pyproject" : "" ,
165
+ },
166
+ )
167
+ config = pytester .parseconfig (pytester .path / "foo/bar" )
168
+ assert config .inipath == pytester .path / "foo/bar/pyproject.toml"
169
+
170
+ def test_pytest_ini_trumps_pyproject_toml (self , pytester : Pytester ) -> None :
171
+ """An empty pyproject.toml is considered as config if no other option is found."""
172
+ pytester .makepyprojecttoml ("[tool.pytest.ini_options]" )
173
+ pytest_ini = pytester .makefile (".ini" , pytest = "" )
174
+ config = pytester .parseconfig ()
175
+ assert config .inipath == pytest_ini
176
+
147
177
def test_toxini_before_lower_pytestini (self , pytester : Pytester ) -> None :
148
178
sub = pytester .mkdir ("sub" )
149
179
sub .joinpath ("tox.ini" ).write_text (
0 commit comments