@@ -58,10 +58,17 @@ def main() -> None:
58
58
"only use this option if you trust the package you are testing."
59
59
),
60
60
)
61
+ parser .add_argument (
62
+ "--python-version" ,
63
+ default = _PYTHON_VERSION ,
64
+ choices = ("3.8" , "3.9" , "3.10" , "3.11" , "3.12" ),
65
+ help = "Target Python version for the test (default: %(default)s)." ,
66
+ )
61
67
parser .add_argument ("path" , help = "Path of the stub to test in format <folder>/<stub>, from the root of the project." )
62
68
args = parser .parse_args ()
63
69
path : str = args .path
64
70
run_stubtest : bool = args .run_stubtest
71
+ python_version : str = args .python_version
65
72
66
73
path_tokens = Path (path ).parts
67
74
if len (path_tokens ) != 2 :
@@ -94,9 +101,9 @@ def main() -> None:
94
101
check_new_syntax_result = subprocess .run ([sys .executable , "tests/check_new_syntax.py" ])
95
102
96
103
strict_params = _get_strict_params (path )
97
- print (f"\n Running Pyright ({ 'stricter' if strict_params else 'base' } configs) for Python { _PYTHON_VERSION } ..." )
104
+ print (f"\n Running Pyright ({ 'stricter' if strict_params else 'base' } configs) for Python { python_version } ..." )
98
105
pyright_result = subprocess .run (
99
- [sys .executable , "tests/pyright_test.py" , path , "--pythonversion" , _PYTHON_VERSION ] + strict_params ,
106
+ [sys .executable , "tests/pyright_test.py" , path , "--pythonversion" , python_version ] + strict_params ,
100
107
stderr = subprocess .PIPE ,
101
108
text = True ,
102
109
)
@@ -109,8 +116,8 @@ def main() -> None:
109
116
pyright_returncode = pyright_result .returncode
110
117
pyright_skipped = False
111
118
112
- print (f"\n Running mypy for Python { _PYTHON_VERSION } ..." )
113
- mypy_result = subprocess .run ([sys .executable , "tests/mypy_test.py" , path , "--python-version" , _PYTHON_VERSION ])
119
+ print (f"\n Running mypy for Python { python_version } ..." )
120
+ mypy_result = subprocess .run ([sys .executable , "tests/mypy_test.py" , path , "--python-version" , python_version ])
114
121
# If mypy failed, stubtest will fail without any helpful error
115
122
if mypy_result .returncode == 0 :
116
123
if folder == "stdlib" :
@@ -146,13 +153,13 @@ def main() -> None:
146
153
pyright_testcases_skipped = False
147
154
regr_test_returncode = 0
148
155
else :
149
- print (f"\n Running Pyright regression tests for Python { _PYTHON_VERSION } ..." )
156
+ print (f"\n Running Pyright regression tests for Python { python_version } ..." )
150
157
command = [
151
158
sys .executable ,
152
159
"tests/pyright_test.py" ,
153
160
str (test_cases_path ),
154
161
"--pythonversion" ,
155
- _PYTHON_VERSION ,
162
+ python_version ,
156
163
"-p" ,
157
164
_TESTCASES_CONFIG_FILE ,
158
165
]
@@ -166,9 +173,9 @@ def main() -> None:
166
173
pyright_testcases_returncode = pyright_testcases_result .returncode
167
174
pyright_testcases_skipped = False
168
175
169
- print (f"\n Running mypy regression tests for Python { _PYTHON_VERSION } ..." )
176
+ print (f"\n Running mypy regression tests for Python { python_version } ..." )
170
177
regr_test_result = subprocess .run (
171
- [sys .executable , "tests/regr_test.py" , "stdlib" if folder == "stdlib" else stub , "--python-version" , _PYTHON_VERSION ],
178
+ [sys .executable , "tests/regr_test.py" , "stdlib" if folder == "stdlib" else stub , "--python-version" , python_version ],
172
179
stderr = subprocess .PIPE ,
173
180
text = True ,
174
181
)
0 commit comments