osbuild: setup isort autochecking
The `test-src` makefile target now also runs isort against all source files and reports errors.
This commit is contained in:
parent
a5be1cc4d2
commit
98daf1a87d
3 changed files with 31 additions and 0 deletions
1
.git-blame-ignore-revs
Normal file
1
.git-blame-ignore-revs
Normal file
|
|
@ -0,0 +1 @@
|
|||
1be3f1bfb671fa6d59dcd2203f23e1625194574b
|
||||
|
|
@ -68,6 +68,19 @@ def test_mypy():
|
|||
pytest.fail("mypy issues detected")
|
||||
|
||||
|
||||
@pytest.mark.skipif(not test.TestBase.have_isort(), reason="isort not available")
|
||||
def test_isort(source_files):
|
||||
#
|
||||
# Run `isort` on all python sources. We simply use `find` to locate
|
||||
# all `*.py` files, and then manually select the reverse-domain named
|
||||
# modules we have.
|
||||
#
|
||||
|
||||
r = subprocess.run(["isort", "-c"] + source_files, check=False)
|
||||
if r.returncode != 0:
|
||||
pytest.fail("isort issues detected")
|
||||
|
||||
|
||||
@pytest.mark.skipif(not test.TestBase.have_autopep8(), reason="autopep8 not available")
|
||||
def test_autopep8(source_files):
|
||||
r = subprocess.run(["autopep8-3", "--diff", "--exit-code"] + source_files, check=False)
|
||||
|
|
|
|||
17
test/test.py
17
test/test.py
|
|
@ -203,6 +203,23 @@ class TestBase(unittest.TestCase):
|
|||
|
||||
return r.returncode == 0 and "mypy" in r.stdout
|
||||
|
||||
def have_isort() -> bool:
|
||||
"""Check isort Availability
|
||||
|
||||
This checks whether `isort` is available in the current path and
|
||||
can be called by this process.
|
||||
"""
|
||||
|
||||
try:
|
||||
r = subprocess.run(
|
||||
["isort", "--version"],
|
||||
encoding="utf-8", stdout=subprocess.PIPE, check=False
|
||||
)
|
||||
except FileNotFoundError:
|
||||
return False
|
||||
|
||||
return r.returncode == 0 and "isort" in r.stdout
|
||||
|
||||
@staticmethod
|
||||
def have_rpm_ostree() -> bool:
|
||||
"""Check rpm-ostree Availability
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue