test: add have_autopep8 method

Add a helper to check if the `autopep8` command is available.
This commit is contained in:
Christian Kellner 2022-08-04 16:52:27 +02:00
parent 620f7c0f3e
commit bb644cdd07

View file

@ -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