Skip to content

Commit aaeb707

Browse files
Robert Schützelprans
authored andcommitted
Check for .flake8 after importing flake8
This way, tests won't fail if both the flake8 module and the .flake8 file are missing.
1 parent e3ad12d commit aaeb707

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tests/test__sourcecode.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ def find_root():
1717
class TestFlake8(unittest.TestCase):
1818

1919
def test_flake8(self):
20-
root_path = find_root()
21-
config_path = os.path.join(root_path, '.flake8')
22-
if not os.path.exists(config_path):
23-
raise RuntimeError('could not locate .flake8 file')
24-
2520
try:
2621
import flake8 # NoQA
2722
except ImportError:
2823
raise unittest.SkipTest('flake8 module is missing')
2924

25+
root_path = find_root()
26+
config_path = os.path.join(root_path, '.flake8')
27+
if not os.path.exists(config_path):
28+
raise RuntimeError('could not locate .flake8 file')
29+
3030
try:
3131
subprocess.run(
3232
[sys.executable, '-m', 'flake8', '--config', config_path],

0 commit comments

Comments
 (0)