1import pathlib 2import unittest 3 4import mypy.api 5 6test_modules = ['rsa', 'tests'] 7 8 9class MypyRunnerTest(unittest.TestCase): 10 def test_run_mypy(self): 11 proj_root = pathlib.Path(__file__).parent.parent 12 args = ['--incremental', '--ignore-missing-imports'] + [str(proj_root / dirname) for dirname 13 in test_modules] 14 15 result = mypy.api.run(args) 16 17 stdout, stderr, status = result 18 19 messages = [] 20 if stderr: 21 messages.append(stderr) 22 if stdout: 23 messages.append(stdout) 24 if status: 25 messages.append('Mypy failed with status %d' % status) 26 if messages and not all('Success' in message for message in messages): 27 self.fail('\n'.join(['Mypy errors:'] + messages)) 28