[Python-checkins] r63522 - python/trunk/Lib/ctypes/test/__init__.py
thomas.heller
python-checkins at python.org
Wed May 21 20:47:02 CEST 2008
Author: thomas.heller
Date: Wed May 21 20:47:02 2008
New Revision: 63522
Log:
The -x <test1[,test2...]> flag allows to exclude tests.
Modified:
python/trunk/Lib/ctypes/test/__init__.py
Modified: python/trunk/Lib/ctypes/test/__init__.py
==============================================================================
--- python/trunk/Lib/ctypes/test/__init__.py (original)
+++ python/trunk/Lib/ctypes/test/__init__.py Wed May 21 20:47:02 2008
@@ -50,11 +50,16 @@
if fnmatch.fnmatchcase(fnm, mask):
yield "%s.%s" % (package.__name__, os.path.splitext(fnm)[0])
-def get_tests(package, mask, verbosity):
+def get_tests(package, mask, verbosity, exclude):
"""Return a list of skipped test modules, and a list of test cases."""
tests = []
skipped = []
for modname in find_package_modules(package, mask):
+ if modname.split(".")[-1] in exclude:
+ skipped.append(modname)
+ if verbosity > 1:
+ print >> sys.stderr, "Skipped %s: excluded" % modname
+ continue
try:
mod = __import__(modname, globals(), locals(), ['*'])
except ResourceDenied, detail:
@@ -151,12 +156,13 @@
def main(*packages):
try:
- opts, args = getopt.getopt(sys.argv[1:], "rqvu:")
+ opts, args = getopt.getopt(sys.argv[1:], "rqvu:x:")
except getopt.error:
return usage()
verbosity = 1
search_leaks = False
+ exclude = []
for flag, value in opts:
if flag == "-q":
verbosity -= 1
@@ -171,17 +177,19 @@
search_leaks = True
elif flag == "-u":
use_resources.extend(value.split(","))
+ elif flag == "-x":
+ exclude.append(value.split(","))
mask = "test_*.py"
if args:
mask = args[0]
for package in packages:
- run_tests(package, mask, verbosity, search_leaks)
+ run_tests(package, mask, verbosity, search_leaks, exclude)
-def run_tests(package, mask, verbosity, search_leaks):
- skipped, testcases = get_tests(package, mask, verbosity)
+def run_tests(package, mask, verbosity, search_leaks, exclude):
+ skipped, testcases = get_tests(package, mask, verbosity, exclude)
runner = TestRunner(verbosity=verbosity)
suites = [unittest.makeSuite(o) for o in testcases]
More information about the Python-checkins
mailing list