1
1
#! /usr/bin/env python
2
2
from __future__ import print_function
3
3
4
- import subprocess
5
4
import sys
6
5
7
6
import pytest
11
10
'fast' : ['tests' , '--tb=short' , '-q' , '-s' , '-rw' ],
12
11
}
13
12
14
- FLAKE8_ARGS = ['rest_framework' , 'tests' ]
15
-
16
- ISORT_ARGS = ['--recursive' , '--check-only' , '-o' 'uritemplate' , '-p' , 'tests' , 'rest_framework' , 'tests' ]
17
-
18
13
19
14
def exit_on_failure (ret , message = None ):
20
15
if ret :
21
16
sys .exit (ret )
22
17
23
18
24
- def flake8_main (args ):
25
- print ('Running flake8 code linting' )
26
- ret = subprocess .call (['flake8' ] + args )
27
- print ('flake8 failed' if ret else 'flake8 passed' )
28
- return ret
29
-
30
-
31
- def isort_main (args ):
32
- print ('Running isort code checking' )
33
- ret = subprocess .call (['isort' ] + args )
34
-
35
- if ret :
36
- print ('isort failed: Some modules have incorrectly ordered imports. Fix by running `isort --recursive .`' )
37
- else :
38
- print ('isort passed' )
39
-
40
- return ret
41
-
42
-
43
19
def split_class_and_function (string ):
44
20
class_string , function_string = string .split ('.' , 1 )
45
21
return "%s and %s" % (class_string , function_string )
@@ -56,22 +32,6 @@ def is_class(string):
56
32
57
33
58
34
if __name__ == "__main__" :
59
- try :
60
- sys .argv .remove ('--nolint' )
61
- except ValueError :
62
- run_flake8 = True
63
- run_isort = True
64
- else :
65
- run_flake8 = False
66
- run_isort = False
67
-
68
- try :
69
- sys .argv .remove ('--lintonly' )
70
- except ValueError :
71
- run_tests = True
72
- else :
73
- run_tests = False
74
-
75
35
try :
76
36
sys .argv .remove ('--fast' )
77
37
except ValueError :
@@ -110,11 +70,4 @@ def is_class(string):
110
70
else :
111
71
pytest_args = PYTEST_ARGS [style ]
112
72
113
- if run_tests :
114
- exit_on_failure (pytest .main (pytest_args ))
115
-
116
- if run_flake8 :
117
- exit_on_failure (flake8_main (FLAKE8_ARGS ))
118
-
119
- if run_isort :
120
- exit_on_failure (isort_main (ISORT_ARGS ))
73
+ exit_on_failure (pytest .main (pytest_args ))
0 commit comments