diff --git a/AUTHORS b/AUTHORS index e11400c1f..d0e584f63 100644 --- a/AUTHORS +++ b/AUTHORS @@ -70,6 +70,7 @@ Daniel Hahler Daniel Nuri Daniel Wandschneider Danielle Jenkins +Daniil Galiev Dave Hunt David Díaz-Barquero David Mohr diff --git a/changelog/6194.bugfix.rst b/changelog/6194.bugfix.rst new file mode 100644 index 000000000..92e6aec78 --- /dev/null +++ b/changelog/6194.bugfix.rst @@ -0,0 +1 @@ +Fix incorrect discovery of non-test ``__init__.py`` files. diff --git a/changelog/6197.bugfix.rst b/changelog/6197.bugfix.rst new file mode 100644 index 000000000..9bd0a5a65 --- /dev/null +++ b/changelog/6197.bugfix.rst @@ -0,0 +1 @@ +Revert "The first test in a package (``__init__.py``) marked with ``@pytest.mark.skip`` is now correctly skipped.". diff --git a/testing/test_collection.py b/testing/test_collection.py index dee07d5c7..8050e80f9 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -1257,3 +1257,24 @@ def test_collector_respects_tbstyle(testdir): "*= 1 error in *", ] ) + + +def test_does_not_eagerly_collect_packages(testdir): + testdir.makepyfile("def test(): pass") + pydir = testdir.mkpydir("foopkg") + pydir.join("__init__.py").write("assert False") + result = testdir.runpytest() + assert result.ret == ExitCode.OK + + +def test_does_not_put_src_on_path(testdir): + # `src` is not on sys.path so it should not be importable + testdir.tmpdir.join("src/nope/__init__.py").ensure() + testdir.makepyfile( + "import pytest\n" + "def test():\n" + " with pytest.raises(ImportError):\n" + " import nope\n" + ) + result = testdir.runpytest() + assert result.ret == ExitCode.OK