X-Git-Url: http://average.org/gitweb/?a=blobdiff_plain;f=test%2Ftest_black.py;h=76275af47918482a706ffdebd64edf9dc8a1c0ff;hb=6eff65f7b03bc66a479df0fd694250e1e0b7c5ae;hp=77262077dc99cad8a7c40a8fe33ecc3ef00cae03;hpb=4a8e1a23b342cb33085d9832937108801245e7d5;p=loctrkd.git diff --git a/test/test_black.py b/test/test_black.py index 7726207..76275af 100644 --- a/test/test_black.py +++ b/test/test_black.py @@ -3,25 +3,32 @@ from pkg_resources import get_distribution, DistributionNotFound from re import match from subprocess import run from shutil import which -from unittest import TestCase, skipUnless +from unittest import main, TestCase, skipUnless -black_version = 0.0 +from . import no_less_than + +is_acceptable_verison = no_less_than("21.1") + +black_version = "0.0" try: vermatch = match("[\.\d]*", get_distribution("black").version) if vermatch is not None: - black_version = float(vermatch.group()) + black_version = vermatch.group() except DistributionNotFound: pass class BlackFormatter(TestCase): - @skipUnless(black_version >= 21.1, "Do not trust earlier black versions") + @skipUnless( + is_acceptable_verison(black_version), + "Do not trust earlier black versions", + ) def test_black(self) -> None: if not which("black"): self.fail(f"black not installed.") cmd = ( ["black", "--check", "--diff", "-l", "79"] - + glob("gps303/**/*.py", recursive=True) + + glob("loctrkd/**/*.py", recursive=True) + glob("test/**/*.py", recursive=True) ) output = run(cmd, capture_output=True) @@ -33,3 +40,7 @@ class BlackFormatter(TestCase): self.fail( f"black exited with code {output.returncode}:\n{output.stderr.decode()}" ) + + +if __name__ == "__main__": + main()