Skip to content

Commit 4e0f992

Browse files
committed
Add regression tests for __init__.py breakage
1 parent 176c777 commit 4e0f992

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ Daniel Hahler
7070
Daniel Nuri
7171
Daniel Wandschneider
7272
Danielle Jenkins
73+
Daniil Galiev
7374
Dave Hunt
7475
David Díaz-Barquero
7576
David Mohr

changelog/6194.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix incorrect discovery of non-test ``__init__.py`` files.

changelog/6197.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Revert "The first test in a package (``__init__.py``) marked with ``@pytest.mark.skip`` is now correctly skipped.".

testing/test_collection.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,3 +1257,24 @@ def test_collector_respects_tbstyle(testdir):
12571257
"*= 1 error in *",
12581258
]
12591259
)
1260+
1261+
1262+
def test_does_not_eagerly_collect_packages(testdir):
1263+
testdir.makepyfile("def test(): pass")
1264+
pydir = testdir.mkpydir("foopkg")
1265+
pydir.join("__init__.py").write("assert False")
1266+
result = testdir.runpytest()
1267+
assert result.ret == ExitCode.OK
1268+
1269+
1270+
def test_does_not_put_src_on_path(testdir):
1271+
# `src` is not on sys.path so it should not be importable
1272+
testdir.tmpdir.join("src/nope/__init__.py").ensure()
1273+
testdir.makepyfile(
1274+
"import pytest\n"
1275+
"def test():\n"
1276+
" with pytest.raises(ImportError):\n"
1277+
" import nope\n"
1278+
)
1279+
result = testdir.runpytest()
1280+
assert result.ret == ExitCode.OK

0 commit comments

Comments
 (0)