23
23
24
24
import pytest
25
25
26
- from pylint .testutils import _get_tests_info , linter
26
+ from pylint .testutils import UPDATE_FILE , UPDATE_OPTION , _get_tests_info , linter
27
27
28
28
# Configure paths
29
29
INPUT_DIR = join (dirname (abspath (__file__ )), "input" )
30
30
MSG_DIR = join (dirname (abspath (__file__ )), "messages" )
31
31
32
32
33
33
FILTER_RGX = None
34
- UPDATE = False
35
34
INFO_TEST_RGX = re .compile (r"^func_i\d\d\d\d$" )
36
35
37
36
# Classes
@@ -119,7 +118,7 @@ def gen_tests(filter_rgx):
119
118
base = module_file .replace (".py" , "" ).split ("_" )[1 ]
120
119
dependencies = _get_tests_info (INPUT_DIR , MSG_DIR , base , ".py" )
121
120
tests .append ((module_file , messages_file , dependencies ))
122
- if UPDATE :
121
+ if UPDATE_FILE . exists () :
123
122
return tests
124
123
assert len (tests ) < 196 , "Please do not add new test cases here."
125
124
return tests
@@ -149,7 +148,7 @@ def test_functionality(module_file, messages_file, dependencies, recwarn):
149
148
150
149
151
150
def __test_functionality (module_file , messages_file , dependencies ):
152
- lint_test = LintTestUpdate () if UPDATE else LintTestUsingModule ()
151
+ lint_test = LintTestUpdate () if UPDATE_FILE . exists () else LintTestUsingModule ()
153
152
lint_test .module = module_file .replace (".py" , "" )
154
153
lint_test .output = messages_file
155
154
lint_test .depends = dependencies or None
@@ -158,11 +157,12 @@ def __test_functionality(module_file, messages_file, dependencies):
158
157
159
158
160
159
if __name__ == "__main__" :
161
- if "-u" in sys .argv :
162
- UPDATE = True
163
- sys .argv .remove ("-u" )
164
-
160
+ if UPDATE_OPTION in sys .argv :
161
+ UPDATE_FILE .touch ()
162
+ sys .argv .remove (UPDATE_OPTION )
165
163
if len (sys .argv ) > 1 :
166
164
FILTER_RGX = sys .argv [1 ]
167
165
del sys .argv [1 ]
168
166
pytest .main (sys .argv )
167
+ if UPDATE_FILE .exists ():
168
+ UPDATE_FILE .unlink ()
0 commit comments