From bb644cdd079150802ec2a4aeab3def275b008b05 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Thu, 4 Aug 2022 16:52:27 +0200 Subject: [PATCH] test: add have_autopep8 method Add a helper to check if the `autopep8` command is available. --- test/test.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/test.py b/test/test.py index 723c1f23..d4cdd8c7 100644 --- a/test/test.py +++ b/test/test.py @@ -167,6 +167,24 @@ class TestBase(unittest.TestCase): check=False, ) + @staticmethod + def have_autopep8() -> bool: + """Check autopep8 Availability + + This checks whether `autopep8` is available in the current path and + can be called by this process. + """ + + try: + r = subprocess.run( + ["autopep8-3", "--version"], + encoding="utf-8", stdout=subprocess.PIPE, check=False + ) + except FileNotFoundError: + return False + + return r.returncode == 0 and "autopep8" in r.stdout + @staticmethod def have_rpm_ostree() -> bool: """Check rpm-ostree Availability