Sybren A. Stüvel | 6760eb7 | 2019-08-04 15:47:11 +0200 | [diff] [blame] | 1 | import pathlib |
| 2 | import unittest |
| 3 | |
| 4 | import mypy.api |
| 5 | |
| 6 | test_modules = ['rsa', 'tests'] |
| 7 | |
| 8 | |
| 9 | class 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üvel | 5c7696d | 2020-06-11 18:36:20 +0200 | [diff] [blame] | 26 | if messages and not all('Success' in message for message in messages): |
Sybren A. Stüvel | 6760eb7 | 2019-08-04 15:47:11 +0200 | [diff] [blame] | 27 | self.fail('\n'.join(['Mypy errors:'] + messages)) |