@@ -54,13 +54,19 @@ def test_mypy_ignore_missings_imports(testdir, xdist_args):
5454 Verify that --mypy-ignore-missing-imports
5555 causes mypy to ignore missing imports.
5656 """
57+ module_name = 'is_always_missing'
5758 testdir .makepyfile ('''
58- import pytest_mypy
59- ''' )
59+ try:
60+ import {module_name}
61+ except ImportError:
62+ pass
63+ ''' .format (module_name = module_name ))
6064 result = testdir .runpytest_subprocess ('--mypy' , * xdist_args )
6165 result .assert_outcomes (failed = 1 )
6266 result .stdout .fnmatch_lines ([
63- "1: error: Cannot find *module named 'pytest_mypy'" ,
67+ "2: error: Cannot find *module named '{module_name}'" .format (
68+ module_name = module_name ,
69+ ),
6470 ])
6571 assert result .ret != 0
6672 result = testdir .runpytest_subprocess (
@@ -88,13 +94,15 @@ def test_fails():
8894def test_non_mypy_error (testdir , xdist_args ):
8995 """Verify that non-MypyError exceptions are passed through the plugin."""
9096 message = 'This is not a MypyError.'
91- testdir .makepyfile ('''
92- import pytest_mypy
97+ testdir .makepyfile (conftest = '''
98+ def pytest_configure(config):
99+ plugin = config.pluginmanager.getplugin('mypy')
93100
94- def _patched_runtest(*args, **kwargs):
95- raise Exception('{message}')
101+ class PatchedMypyItem(plugin.MypyItem):
102+ def runtest(self):
103+ raise Exception('{message}')
96104
97- pytest_mypy .MypyItem.runtest = _patched_runtest
105+ plugin .MypyItem = PatchedMypyItem
98106 ''' .format (message = message ))
99107 result = testdir .runpytest_subprocess (* xdist_args )
100108 result .assert_outcomes ()
0 commit comments