X-Git-Url: http://average.org/gitweb/?a=blobdiff_plain;f=test%2Ftest_black.py;h=cc72eae03d88bfb2f954f824fbafcf68254787cc;hb=057cce452eb53d5fbe365a66669bd8dec7dfe989;hp=519bc23deea55bdcbd3e80fdf6e96ec29f686641;hpb=b84a40a485b0563d572d14e748ad324185584344;p=loctrkd.git diff --git a/test/test_black.py b/test/test_black.py index 519bc23..cc72eae 100644 --- a/test/test_black.py +++ b/test/test_black.py @@ -1,11 +1,22 @@ from glob import glob +from pkg_resources import get_distribution, DistributionNotFound +from re import match from subprocess import run from shutil import which -from unittest import TestCase +from unittest import main, TestCase, skipUnless + +black_version = 0.0 +try: + vermatch = match("[\.\d]*", get_distribution("black").version) + if vermatch is not None: + black_version = float(vermatch.group()) +except DistributionNotFound: + pass class BlackFormatter(TestCase): - def test_black(self): + @skipUnless(black_version >= 21.1, "Do not trust earlier black versions") + def test_black(self) -> None: if not which("black"): self.fail(f"black not installed.") cmd = ( @@ -22,3 +33,7 @@ class BlackFormatter(TestCase): self.fail( f"black exited with code {output.returncode}:\n{output.stderr.decode()}" ) + + +if __name__ == "__main__": + main()