@@ -214,38 +214,6 @@ def pytest_configure(config):
214214 assert result .ret == 0
215215
216216
217- def test_pytest_collection_modifyitems (testdir , xdist_args ):
218- """
219- Verify that collected files which are removed in a
220- pytest_collection_modifyitems implementation are not
221- checked by mypy.
222-
223- This would also fail if a MypyStatusItem were injected
224- despite there being no MypyFileItems.
225- """
226- testdir .makepyfile (conftest = '''
227- def pytest_collection_modifyitems(session, config, items):
228- plugin = config.pluginmanager.getplugin('mypy')
229- for mypy_item_i in reversed([
230- i
231- for i, item in enumerate(items)
232- if isinstance(item, plugin.MypyFileItem)
233- ]):
234- items.pop(mypy_item_i)
235- ''' )
236- testdir .makepyfile ('''
237- def pyfunc(x: int) -> str:
238- return x * 2
239-
240- def test_pass():
241- pass
242- ''' )
243- result = testdir .runpytest_subprocess ('--mypy' , * xdist_args )
244- test_count = 1
245- result .assert_outcomes (passed = test_count )
246- assert result .ret == 0
247-
248-
249217def test_mypy_indirect (testdir , xdist_args ):
250218 """Verify that uncollected files checked by mypy cause a failure."""
251219 testdir .makepyfile (bad = '''
@@ -259,38 +227,6 @@ def pyfunc(x: int) -> str:
259227 assert result .ret != 0
260228
261229
262- def test_mypy_indirect_inject (testdir , xdist_args ):
263- """
264- Verify that uncollected files checked by mypy because of a MypyFileItem
265- injected in pytest_collection_modifyitems cause a failure.
266- """
267- testdir .makepyfile (bad = '''
268- def pyfunc(x: int) -> str:
269- return x * 2
270- ''' )
271- testdir .makepyfile (good = '''
272- import bad
273- ''' )
274- testdir .makepyfile (conftest = '''
275- import py
276- import pytest
277-
278- @pytest.hookimpl(trylast=True) # Inject as late as possible.
279- def pytest_collection_modifyitems(session, config, items):
280- plugin = config.pluginmanager.getplugin('mypy')
281- items.append(
282- plugin.MypyFileItem.from_parent(
283- parent=session,
284- name=str(py.path.local('good.py')),
285- ),
286- )
287- ''' )
288- name = 'empty'
289- testdir .mkdir (name )
290- result = testdir .runpytest_subprocess ('--mypy' , * xdist_args , name )
291- assert result .ret != 0
292-
293-
294230def test_api_error_formatter (testdir , xdist_args ):
295231 """Ensure that the plugin can be configured in a conftest.py."""
296232 testdir .makepyfile (bad = '''
0 commit comments