summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2008-05-21 18:47:02 (GMT)
committerThomas Heller <theller@ctypes.org>2008-05-21 18:47:02 (GMT)
commit7d9e72158674207e93873a3b649cd19499d55092 (patch)
tree4a012ae7b1ee5c9d8fdca1009eeda00d6c3b0458
parent10cfc4b1f278c6a9ce589338148a23e016b94b5f (diff)
downloadcpython-7d9e72158674207e93873a3b649cd19499d55092.zip
cpython-7d9e72158674207e93873a3b649cd19499d55092.tar.gz
cpython-7d9e72158674207e93873a3b649cd19499d55092.tar.bz2
The -x <test1[,test2...]> flag allows to exclude tests.
-rw-r--r--Lib/ctypes/test/__init__.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/Lib/ctypes/test/__init__.py b/Lib/ctypes/test/__init__.py
index 339ec8b..24738ea 100644
--- a/Lib/ctypes/test/__init__.py
+++ b/Lib/ctypes/test/__init__.py
@@ -50,11 +50,16 @@ def find_package_modules(package, mask):
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 @@ class TestRunner(unittest.TextTestRunner):
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 @@ def main(*packages):
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]