| 17 | class TestCodeQuality(unittest.TestCase): |
| 18 | |
| 19 | def test_flake8(self): |
| 20 | try: |
| 21 | import flake8 # NoQA |
| 22 | except ImportError: |
| 23 | raise unittest.SkipTest('flake8 module is missing') |
| 24 | |
| 25 | root_path = find_root() |
| 26 | config_path = os.path.join(root_path, '.flake8') |
| 27 | if not os.path.exists(config_path): |
| 28 | raise RuntimeError('could not locate .flake8 file') |
| 29 | |
| 30 | try: |
| 31 | subprocess.run( |
| 32 | [sys.executable, '-m', 'flake8', '--config', config_path], |
| 33 | check=True, |
| 34 | stdout=subprocess.PIPE, |
| 35 | stderr=subprocess.STDOUT, |
| 36 | cwd=root_path) |
| 37 | except subprocess.CalledProcessError as ex: |
| 38 | output = ex.output.decode() |
| 39 | raise AssertionError( |
| 40 | 'flake8 validation failed:\n{}'.format(output)) from None |
| 41 | |
| 42 | def test_mypy(self): |
| 43 | try: |