X-Git-Url: http://www.average.org/gitweb/?a=blobdiff_plain;f=test%2Ftest_mypy.py;h=d2020d4ff7b2eb6f5abcf6b611395ba1e69c8d4f;hb=3586e90376646848c984e7aa1c133d8b4836feff;hp=3b8eaaf2368476e432f506988a5e7380bba60c58;hpb=b84a40a485b0563d572d14e748ad324185584344;p=loctrkd.git diff --git a/test/test_mypy.py b/test/test_mypy.py index 3b8eaaf..d2020d4 100644 --- a/test/test_mypy.py +++ b/test/test_mypy.py @@ -1,15 +1,25 @@ -from subprocess import run +from pkg_resources import get_distribution, DistributionNotFound +from subprocess import call from shutil import which -from unittest import TestCase +from unittest import skipUnless, TestCase + +mypy_version = 0.0 +try: + mypy_version = float(get_distribution("mypy").version) +except DistributionNotFound: + pass class TypeCheck(TestCase): - def test_mypy(self): + @skipUnless(mypy_version >= 0.942, "Do not trust earlier mypy versions") + def test_mypy(self) -> None: if not which("mypy"): - self.fail(f"mypy not installed.") - cmd = ["mypy", "--strict", "--ignore-missing-imports", "gps303"] - output = run(cmd, capture_output=True) - if output.returncode != 0: - self.fail( - f"mypy exited with code {output.returncode}:\n{output.stderr.decode()}" - ) + self.fail("mypy not installed.") + cmd = [ + "mypy", + "--strict", + "--ignore-missing-imports", + "gps303", + "test", + ] + self.assertEqual(call(cmd), 0, "mypy typecheck")