mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-28 00:49:49 +03:00
Use suppress instead of try/except/else
This commit is contained in:
parent
acbd9d8222
commit
11180856f6
24
runtests.py
24
runtests.py
|
@ -1,6 +1,7 @@
|
|||
#! /usr/bin/env python3
|
||||
import subprocess
|
||||
import sys
|
||||
from contextlib import suppress
|
||||
|
||||
import pytest
|
||||
|
||||
|
@ -54,27 +55,21 @@ def is_class(string):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
sys.argv.remove('--nolint')
|
||||
except ValueError:
|
||||
run_flake8 = True
|
||||
run_isort = True
|
||||
else:
|
||||
with suppress(ValueError):
|
||||
sys.argv.remove('--nolint')
|
||||
run_flake8 = False
|
||||
run_isort = False
|
||||
|
||||
try:
|
||||
sys.argv.remove('--lintonly')
|
||||
except ValueError:
|
||||
run_tests = True
|
||||
else:
|
||||
with suppress(ValueError):
|
||||
sys.argv.remove('--lintonly')
|
||||
run_tests = False
|
||||
|
||||
try:
|
||||
sys.argv.remove('--fast')
|
||||
except ValueError:
|
||||
style = 'default'
|
||||
else:
|
||||
with suppress(ValueError):
|
||||
sys.argv.remove('--fast')
|
||||
style = 'fast'
|
||||
run_flake8 = False
|
||||
run_isort = False
|
||||
|
@ -83,11 +78,8 @@ if __name__ == "__main__":
|
|||
pytest_args = sys.argv[1:]
|
||||
first_arg = pytest_args[0]
|
||||
|
||||
try:
|
||||
with suppress(ValueError):
|
||||
pytest_args.remove('--coverage')
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
pytest_args = [
|
||||
'--cov', '.',
|
||||
'--cov-report', 'xml',
|
||||
|
|
Loading…
Reference in New Issue
Block a user