1 """Supporting definitions for the Python regression test."""
4 class Error(Exception):
5 """Base class for regression test exceptions."""
7 class TestFailed(Error
):
10 class TestSkipped(Error
):
13 This can be raised to indicate that a test was deliberatly
14 skipped, but not because a feature wasn't available. For
15 example, if some resource can't be used, such as the network
16 appears to be unavailable, this should be raised instead of
22 verbose
= 1 # Flag set to 0 by regrtest.py
23 use_large_resources
= 1 # Flag set to 0 by regrtest.py
35 for dirname
in sys
.path
:
37 os
.unlink(os
.path
.join(dirname
, modname
+ '.pyc'))
43 def fcmp(x
, y
): # fuzzy comparison function
44 if type(x
) == type(0.0) or type(y
) == type(0.0):
47 fuzz
= (abs(x
) + abs(y
)) * FUZZ
52 elif type(x
) == type(y
) and type(x
) in (type(()), type([])):
53 for i
in range(min(len(x
), len(y
))):
54 outcome
= fcmp(x
[i
], y
[i
])
57 return cmp(len(x
), len(y
))
60 TESTFN
= '@test' # Filename used for testing
63 def findfile(file, here
=__file__
):
65 if os
.path
.isabs(file):
69 path
= [os
.path
.dirname(here
)] + path
71 fn
= os
.path
.join(dn
, file)
72 if os
.path
.exists(fn
): return fn