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

Skip to content

Commit fe3f696

Browse files
committed
Two small changes to the resource usage option:
(1) Allow multiple -u options to extend each other (and the initial value of use_resources passed into regrtest.main()). (2) When a test is run stand-alone (not via regrtest.py), needed resources are always granted.
1 parent 6091cd6 commit fe3f696

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

Lib/test/regrtest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,11 @@ def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0,
115115
elif o in ('-l', '--findleaks'):
116116
findleaks = 1
117117
elif o in ('-u', '--use'):
118-
use_resources = [x.lower() for x in a.split(',')]
119-
for r in use_resources:
118+
u = [x.lower() for x in a.split(',')]
119+
for r in u:
120120
if r not in ('largefile', 'network'):
121121
usage(1, 'Invalid -u/--use option: %s' % a)
122+
use_resources.extend(u)
122123
if generate and verbose:
123124
usage(2, "-g and -v don't go together!")
124125

Lib/test/test_support.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class TestSkipped(Error):
2020
"""
2121

2222
verbose = 1 # Flag set to 0 by regrtest.py
23-
use_resources = [] # Flag set to [] by regrtest.py
23+
use_resources = None # Flag set to [] by regrtest.py
2424

2525
def unload(name):
2626
try:
@@ -38,7 +38,7 @@ def forget(modname):
3838
pass
3939

4040
def requires(resource, msg=None):
41-
if resource not in use_resources:
41+
if use_resources is not None and resource not in use_resources:
4242
if msg is None:
4343
msg = "Use of the `%s' resource not enabled" % resource
4444
raise TestSkipped(msg)

0 commit comments

Comments
 (0)