Skip to content

Commit 2f0f33a

Browse files
committed
Test for sort imports
Sorting imports has been an unwritten coding style of our codebase. This commit makes it into a test rule. Signed-off-by: Hritik Vijay <hritikxx8@gmail.com>
1 parent 1ca9ece commit 2f0f33a

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

pyproject.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,10 @@ addopts = [
4343
"-rfExXw",
4444
"--strict",
4545
"--doctest-modules"
46-
]
46+
]
47+
48+
[tool.isort]
49+
profile = "black"
50+
line_length = 100
51+
atomic = true
52+
multi_line_output = 3

vulnerabilities/tests/test_basics.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@
2020
# VulnerableCode is a free software code scanning tool from nexB Inc. and others.
2121
# Visit https://github.com/nexB/vulnerablecode/ for support and download.
2222

23-
from os.path import dirname
24-
from os.path import join
2523
import subprocess
2624
import sys
2725
import unittest
26+
from os.path import dirname, join
2827

2928
root_dir = dirname(dirname(dirname(__file__)))
3029
bin_dir = dirname(sys.executable)
@@ -37,3 +36,9 @@ def test_codestyle(self):
3736
subprocess.check_output(args.split(), cwd=root_dir)
3837
except Exception as e:
3938
raise Exception(f"Black style check failed, please format the code using black") from e
39+
40+
args = join(bin_dir, "isort -c .")
41+
try:
42+
subprocess.check_output(args.split(), cwd=root_dir)
43+
except Exception as e:
44+
raise Exception("Unsorted imports, please sort your imports using isort") from e

0 commit comments

Comments
 (0)