Skip to content

Commit 3f105b4

Browse files
committed
Add test for setup.cfg indicator only if setup.py
1 parent 232d614 commit 3f105b4

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

testing/test_collection.py

+20
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,26 @@ def test_build_dirs_collected(
297297
result = pytester.runpytest("--collect-only").stdout.str()
298298
assert "test_module" not in result
299299

300+
@known_build_dirs
301+
def test_build_dirs_collected_when_setuptools_configuration_present(
302+
self, pytester: Pytester, build_dir: str
303+
) -> None:
304+
tmp_path = pytester.path
305+
ensure_file(tmp_path / build_dir / "test_module.py").write_text(
306+
"def test_hello(): pass", encoding="utf-8"
307+
)
308+
309+
result = pytester.runpytest("--collect-only").stdout.str()
310+
assert "test_module" in result
311+
312+
ensure_file(tmp_path / "setup.cfg")
313+
314+
result = pytester.runpytest("--collect-only").stdout.str()
315+
assert "test_module" in result
316+
317+
ensure_file(tmp_path / "setup.py")
318+
assert "test_module" not in result
319+
300320

301321
class TestCollectPluginHookRelay:
302322
def test_pytest_collect_file(self, pytester: Pytester) -> None:

0 commit comments

Comments
 (0)