From feace5409f3cd3b0abe7f7c829e1f9811684afc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 21 Nov 2018 11:32:11 +0100 Subject: [PATCH] Added MyPy runner to unit tests --- setup.cfg | 1 + tests/test_mypy.py | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tests/test_mypy.py diff --git a/setup.cfg b/setup.cfg index dde7961..41e185c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,6 +6,7 @@ python_version = 3.7 warn_unused_ignores = True ignore_missing_imports = True follow_imports = skip +incremental = True [pep8] max-line-length = 100 diff --git a/tests/test_mypy.py b/tests/test_mypy.py new file mode 100644 index 0000000..969fbbb --- /dev/null +++ b/tests/test_mypy.py @@ -0,0 +1,27 @@ +import pathlib +import unittest + +import mypy.api + +test_modules = ['flamenco_worker', 'tests'] + + +class MypyRunnerTest(unittest.TestCase): + def test_run_mypy(self): + proj_root = pathlib.Path(__file__).parent.parent + args = ['--incremental', '--ignore-missing-imports'] + [str(proj_root / dirname) for dirname + in test_modules] + + result = mypy.api.run(args) + + stdout, stderr, status = result + + messages = [] + if stderr: + messages.append(stderr) + if stdout: + messages.append(stdout) + if status: + messages.append('Mypy failed with status %d' % status) + if messages: + self.fail('\n'.join(['Mypy errors:'] + messages))