| 40 | 'flake8 validation failed:\n{}'.format(output)) from None |
| 41 | |
| 42 | def test_mypy(self): |
| 43 | try: |
| 44 | import mypy # NoQA |
| 45 | except ImportError: |
| 46 | raise unittest.SkipTest('mypy module is missing') |
| 47 | |
| 48 | root_path = find_root() |
| 49 | config_path = os.path.join(root_path, 'pyproject.toml') |
| 50 | if not os.path.exists(config_path): |
| 51 | raise RuntimeError('could not locate mypy.ini file') |
| 52 | |
| 53 | try: |
| 54 | subprocess.run( |
| 55 | [ |
| 56 | sys.executable, |
| 57 | '-m', |
| 58 | 'mypy', |
| 59 | '--config-file', |
| 60 | config_path, |
| 61 | 'asyncpg' |
| 62 | ], |
| 63 | check=True, |
| 64 | stdout=subprocess.PIPE, |
| 65 | stderr=subprocess.STDOUT, |
| 66 | cwd=root_path |
| 67 | ) |
| 68 | except subprocess.CalledProcessError as ex: |
| 69 | output = ex.output.decode() |
| 70 | raise AssertionError( |
| 71 | 'mypy validation failed:\n{}'.format(output)) from None |