From 4a8e1a23b342cb33085d9832937108801245e7d5 Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Tue, 7 Jun 2022 00:43:26 +0200 Subject: [PATCH] do not run black older than 21.1 --- test/test_black.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/test_black.py b/test/test_black.py index 4c34a77..7726207 100644 --- a/test/test_black.py +++ b/test/test_black.py @@ -1,10 +1,21 @@ 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 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): + @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.") -- 2.39.2