blob: 8258e7e692ded03c0e1437c4ceaa890b15c688be [file] [log] [blame]
Sybren A. Stüvel6760eb72019-08-04 15:47:11 +02001import 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)
Sybren A. Stüvel5c7696d2020-06-11 18:36:20 +020026 if messages and not all('Success' in message for message in messages):
Sybren A. Stüvel6760eb72019-08-04 15:47:11 +020027 self.fail('\n'.join(['Mypy errors:'] + messages))