print an error when flake8 is missing

Previously test.py was silently failing if flake8 was not installed. (It
would return an error code, but nothing was printed -- that's how I
missed the lint bug that I had to fix in the last commit.) Now we
explicitly catch that case, and print something helpful.
This commit is contained in:
Jack O'Connor 2015-05-06 13:43:40 -04:00
parent 0822704302
commit 2b6118cd3a
1 changed files with 7 additions and 2 deletions

View File

@ -43,7 +43,8 @@ def main():
command = command_start + ['-m', 'unittest'] + args
try:
subprocess.check_call(command, env=env, cwd=TESTS_DIR)
except:
except subprocess.CalledProcessError:
print('ERROR: unit tests returned an error code', file=sys.stderr)
sys.exit(1)
new_untracked = get_untracked_files()
@ -56,7 +57,11 @@ def main():
# Run the linter.
try:
subprocess.check_call(['flake8', 'peru', 'tests'], cwd=REPO_ROOT)
except:
except FileNotFoundError:
print('ERROR: flake8 not found', file=sys.stderr)
sys.exit(1)
except subprocess.CalledProcessError:
print('ERROR: flake8 returned an error code', file=sys.stderr)
sys.exit(1)