@@ -423,3 +423,28 @@ def test_conftest_exception_handling(testdir):
|
||||
res = testdir.runpytest()
|
||||
assert res.ret == 4
|
||||
assert 'raise ValueError()' in [line.strip() for line in res.errlines]
|
||||
|
||||
|
||||
def test_hook_proxy(testdir):
|
||||
"""Session's gethookproxy() would cache conftests incorrectly (#2016).
|
||||
It was decided to remove the cache altogether.
|
||||
"""
|
||||
testdir.makepyfile(**{
|
||||
'root/demo-0/test_foo1.py': "def test1(): pass",
|
||||
|
||||
'root/demo-a/test_foo2.py': "def test1(): pass",
|
||||
'root/demo-a/conftest.py': """
|
||||
def pytest_ignore_collect(path, config):
|
||||
return True
|
||||
""",
|
||||
|
||||
'root/demo-b/test_foo3.py': "def test1(): pass",
|
||||
'root/demo-c/test_foo4.py': "def test1(): pass",
|
||||
})
|
||||
result = testdir.runpytest()
|
||||
result.stdout.fnmatch_lines([
|
||||
'*test_foo1.py*',
|
||||
'*test_foo3.py*',
|
||||
'*test_foo4.py*',
|
||||
'*3 passed*',
|
||||
])
|
||||
|
||||
@@ -4,7 +4,8 @@ import py
|
||||
import os
|
||||
|
||||
from _pytest.config import get_config, PytestPluginManager
|
||||
from _pytest.main import EXIT_NOTESTSCOLLECTED
|
||||
from _pytest.main import EXIT_NOTESTSCOLLECTED, Session
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pytestpm():
|
||||
@@ -133,6 +134,25 @@ class TestPytestPluginInteractions:
|
||||
finally:
|
||||
undo()
|
||||
|
||||
def test_hook_proxy(self, testdir):
|
||||
"""Test the gethookproxy function(#2016)"""
|
||||
config = testdir.parseconfig()
|
||||
session = Session(config)
|
||||
testdir.makepyfile(**{
|
||||
'tests/conftest.py': '',
|
||||
'tests/subdir/conftest.py': '',
|
||||
})
|
||||
|
||||
conftest1 = testdir.tmpdir.join('tests/conftest.py')
|
||||
conftest2 = testdir.tmpdir.join('tests/subdir/conftest.py')
|
||||
|
||||
config.pluginmanager._importconftest(conftest1)
|
||||
ihook_a = session.gethookproxy(testdir.tmpdir.join('tests'))
|
||||
assert ihook_a is not None
|
||||
config.pluginmanager._importconftest(conftest2)
|
||||
ihook_b = session.gethookproxy(testdir.tmpdir.join('tests'))
|
||||
assert ihook_a is not ihook_b
|
||||
|
||||
def test_warn_on_deprecated_multicall(self, pytestpm):
|
||||
warnings = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user