Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1f872ba

Browse files
committed
run_tests.py: add --current option
1 parent 336a4f4 commit 1f872ba

4 files changed

Lines changed: 35 additions & 15 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ jobs:
1212

1313
script:
1414
- python -VV
15-
- python runtests.py -v
15+
- python runtests.py --current --verbose

README.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,18 @@ Python 3.9
210210
Run tests
211211
=========
212212

213-
Run the command::
213+
Run tests::
214214

215215
python3 runtests.py
216216

217-
Verbose mode::
217+
Only test the current Python version, don't test multiple Python versions
218+
(``-c``, ``--current``)::
218219

219-
python3 runtests.py -v
220+
python3 runtests.py --current
221+
222+
Verbose mode (``-v``, ``--verbose``)::
223+
224+
python3 runtests.py --verbose
220225

221226
See tests in the ``tests/`` subdirectory.
222227

runtests.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
python3 test_matrix.py
88
python3 test_matrix.py -v # verbose mode
99
"""
10+
import argparse
1011
import os.path
12+
import shutil
1113
import subprocess
1214
import sys
13-
import shutil
1415

1516

1617
TEST_DIR = os.path.join(os.path.dirname(__file__), 'tests')
@@ -56,21 +57,35 @@ def run_tests(python, verbose, tested):
5657
run_tests_exe(executable, verbose, tested)
5758

5859

60+
def parse_args():
61+
parser = argparse.ArgumentParser()
62+
parser.add_argument('-v', '--verbose', action="store_true",
63+
help='Verbose mode')
64+
parser.add_argument('-c', '--current', action="store_true",
65+
help="Only test the current Python executable "
66+
"(don't test multiple Python versions)")
67+
return parser.parse_args()
68+
69+
5970
def main():
60-
verbose = "-v" in sys.argv[1:]
71+
args = parse_args()
6172

6273
cmd = [sys.executable, TEST_UPGRADE]
63-
if verbose:
74+
if args.verbose:
6475
cmd.append('-v')
6576
run_command(cmd)
77+
print()
6678

6779
tested = set()
68-
for python in PYTHONS:
69-
run_tests(python, verbose, tested)
70-
run_tests_exe(sys.executable, verbose, tested)
71-
72-
print()
73-
print(f"Tested: {len(tested)} Python executables")
80+
if not args.current:
81+
for python in PYTHONS:
82+
run_tests(python, args.verbose, tested)
83+
run_tests_exe(sys.executable, args.verbose, tested)
84+
85+
print()
86+
print(f"Tested: {len(tested)} Python executables")
87+
else:
88+
run_tests_exe(sys.executable, args.verbose, tested)
7489

7590

7691
if __name__ == "__main__":

tests/test_pythoncapi_compat_cext.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ test_frame(PyObject *self, PyObject *ignored)
8787
// test _PyFrame_GetBackBorrow()
8888
if (back != NULL) {
8989
Py_ssize_t back_refcnt = Py_REFCNT(back);
90-
PyCodeObject *back2 = _PyFrame_GetBackBorrow(frame);
90+
PyFrameObject *back2 = _PyFrame_GetBackBorrow(frame);
9191
assert(back2 == back);
9292
assert(Py_REFCNT(back) == back_refcnt);
9393
}
9494
else {
95-
PyCodeObject *back2 = _PyFrame_GetBackBorrow(frame);
95+
PyFrameObject *back2 = _PyFrame_GetBackBorrow(frame);
9696
assert(back2 == back);
9797
}
9898
Py_XDECREF(back);

0 commit comments

Comments
 (0)