]> www.average.org Git - loctrkd.git/blob - test/test_mypy.py
typecheck: skip test if mypy verison < 0.942
[loctrkd.git] / test / test_mypy.py
1 from pkg_resources import get_distribution, DistributionNotFound
2 from subprocess import call
3 from shutil import which
4 from unittest import skipUnless, TestCase
5
6 mypy_version = 0.0
7 try:
8     mypy_version = float(get_distribution("mypy").version)
9 except DistributionNotFound:
10     pass
11
12
13 class TypeCheck(TestCase):
14     @skipUnless(mypy_version >= 0.942, "Do not trust earlier mypy versions")
15     def test_mypy(self) -> None:
16         if not which("mypy"):
17             self.fail("mypy not installed.")
18         cmd = [
19             "mypy",
20             "--strict",
21             "--ignore-missing-imports",
22             "gps303",
23             "test",
24         ]
25         self.assertEqual(call(cmd), 0, "mypy typecheck")