diff options
author | Anthony Sottile <asottile@umich.edu> | 2019-11-15 08:31:53 -0800 |
---|---|---|
committer | Anthony Sottile <asottile@umich.edu> | 2019-11-15 13:19:31 -0800 |
commit | 4e0f99260d438d750b55a0881110658b8bba5a4a (patch) | |
tree | b527e816c611088848612733b31656206545d692 /testing | |
parent | 176c7771fb4f3bd703bb6c9650cc32e31d548a2b (diff) | |
download | pytest-4e0f99260d438d750b55a0881110658b8bba5a4a.tar.gz |
Add regression tests for __init__.py breakage
Diffstat (limited to 'testing')
-rw-r--r-- | testing/test_collection.py | 21 |
1 files changed, 21 insertions, 0 deletions
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 |