1919python runtests.py -local
2020 Insert '../..' at the beginning of sys.path to use local mpmath
2121
22+ python runtests.py -skip ...
23+ Skip tests from the listed modules
24+
2225Additional arguments are used to filter the tests to run. Only files that have
2326one of the arguments in their name are executed.
2427
5457# TODO: add a flag for this
5558testdir = ''
5659
57- def testit(importdir='', testdir=''):
60+ def testit(importdir='', testdir='', exit_on_fail=False ):
5861 """Run all tests in testdir while importing from importdir."""
5962 if importdir:
6063 sys.path.insert(1, importdir)
@@ -77,6 +80,10 @@ def testit(importdir='', testdir=''):
7780 from timeit import default_timer as clock
7881 modules = []
7982 args = sys.argv[1:]
83+ excluded = []
84+ if '-skip' in args:
85+ excluded = args[args.index('-skip')+1:]
86+ args = args[:args.index('-skip')]
8087 # search for tests in directory of this file if not otherwise specified
8188 if not testdir:
8289 pattern = os.path.dirname(sys.argv[0])
@@ -97,6 +104,8 @@ def testit(importdir='', testdir=''):
97104 break
98105 if not ok:
99106 continue
107+ elif name in excluded:
108+ continue
100109 module = __import__(name)
101110 priority = module.__dict__.get('priority', 100)
102111 if priority == 666:
@@ -124,6 +133,8 @@ def testit(importdir='', testdir=''):
124133 print("TEST FAILED!")
125134 print("")
126135 traceback.print_exc()
136+ if exit_on_fail:
137+ return
127138 t2 = clock()
128139 print("ok " + " " + ("%.7f" % (t2-t1)) + " s")
129140 tend = clock()
0 commit comments