2 from subprocess import run
3 from shutil import which
4 from unittest import TestCase
7 class BlackFormatter(TestCase):
8 def test_black(self) -> None:
10 self.fail(f"black not installed.")
12 ["black", "--check", "--diff", "-l", "79"]
13 + glob("gps303/**/*.py", recursive=True)
14 + glob("test/**/*.py", recursive=True)
16 output = run(cmd, capture_output=True)
17 if output.returncode == 1:
19 f"black found code that needs reformatting:\n{output.stdout.decode()}"
21 if output.returncode != 0:
23 f"black exited with code {output.returncode}:\n{output.stderr.decode()}"