Skip to content

Commit e9ef0d8

Browse files
committed
Add test_pytest_collection_modifyitems
1 parent a79913c commit e9ef0d8

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/test_pytest_mypy.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,26 @@ def pytest_configure(config):
143143
''')
144144
result = testdir.runpytest_subprocess('--mypy', *xdist_args)
145145
assert result.ret == 0
146+
147+
148+
def test_pytest_collection_modifyitems(testdir, xdist_args):
149+
testdir.makepyfile(conftest='''
150+
def pytest_collection_modifyitems(session, config, items):
151+
plugin = config.pluginmanager.getplugin('mypy')
152+
for mypy_item_i in reversed([
153+
i
154+
for i, item in enumerate(items)
155+
if isinstance(item, plugin.MypyItem)
156+
]):
157+
items.pop(mypy_item_i)
158+
''')
159+
testdir.makepyfile('''
160+
def myfunc(x: int) -> str:
161+
return x * 2
162+
163+
def test_pass():
164+
pass
165+
''')
166+
result = testdir.runpytest_subprocess('--mypy', *xdist_args)
167+
result.assert_outcomes(passed=1)
168+
assert result.ret == 0

0 commit comments

Comments
 (0)