Skip to content

Commit 43868dd

Browse files
Merge pull request mpmath#624 from warnerjon12/master
Added test options and small mpf hash fix
2 parents ce7637d + e2eaabd commit 43868dd

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

mpmath/libmp/libmpf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ def mpf_hash(s):
559559
sexp = HASH_BITS - 1 - ((-1 - sexp) % HASH_BITS)
560560
h = (h << sexp) % HASH_MODULUS
561561
if ssign: h = -h
562-
if h == -1: h == -2
562+
if h == -1: h = -2
563563
return int(h)
564564
else:
565565
try:

mpmath/tests/runtests.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
python 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+
2225
Additional arguments are used to filter the tests to run. Only files that have
2326
one of the arguments in their name are executed.
2427

@@ -54,7 +57,7 @@
5457
# TODO: add a flag for this
5558
testdir = ''
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

Comments
 (0)