Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_support.py @ 5817:48b94de85bf3 legacy-trunk
Extensive changes by AMK.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 17 Jul 1997 16:29:42 +0000 |
| parents | a2fd80eed27f |
| children | 047533789359 |
| rev | line source |
|---|---|
| 653 | 1 # Python test set -- supporting definitions. |
| 2 | |
| 3 TestFailed = 'test_support -- test failed' # Exception | |
| 4 | |
|
4791
a2fd80eed27f
Add verbose flag for regression test to clear.
Guido van Rossum <guido@python.org>
parents:
1197
diff
changeset
|
5 verbose = 1 # Flag set to 0 by regrtest.py |
|
a2fd80eed27f
Add verbose flag for regression test to clear.
Guido van Rossum <guido@python.org>
parents:
1197
diff
changeset
|
6 |
| 653 | 7 def unload(name): |
| 8 import sys | |
| 9 try: | |
| 10 del sys.modules[name] | |
| 11 except KeyError: | |
| 12 pass | |
| 13 | |
| 14 def forget(modname): | |
| 15 unload(modname) | |
| 16 import sys, os | |
| 17 for dirname in sys.path: | |
| 18 try: | |
| 19 os.unlink(os.path.join(dirname, modname + '.pyc')) | |
| 20 except os.error: | |
| 21 pass | |
| 22 | |
|
1197
675a02820d66
* os.py: _exit doesn't exist in all variations of posix
Guido van Rossum <guido@python.org>
parents:
653
diff
changeset
|
23 FUZZ = 1e-6 |
|
675a02820d66
* os.py: _exit doesn't exist in all variations of posix
Guido van Rossum <guido@python.org>
parents:
653
diff
changeset
|
24 |
|
675a02820d66
* os.py: _exit doesn't exist in all variations of posix
Guido van Rossum <guido@python.org>
parents:
653
diff
changeset
|
25 def fcmp(x, y): # fuzzy comparison function |
|
675a02820d66
* os.py: _exit doesn't exist in all variations of posix
Guido van Rossum <guido@python.org>
parents:
653
diff
changeset
|
26 if type(x) == type(0.0) or type(y) == type(0.0): |
|
675a02820d66
* os.py: _exit doesn't exist in all variations of posix
Guido van Rossum <guido@python.org>
parents:
653
diff
changeset
|
27 try: |
|
675a02820d66
* os.py: _exit doesn't exist in all variations of posix
Guido van Rossum <guido@python.org>
parents:
653
diff
changeset
|
28 x, y = coerce(x, y) |
|
675a02820d66
* os.py: _exit doesn't exist in all variations of posix
Guido van Rossum <guido@python.org>
parents:
653
diff
changeset
|
29 fuzz = (abs(x) + abs(y)) * FUZZ |
|
675a02820d66
* os.py: _exit doesn't exist in all variations of posix
Guido van Rossum <guido@python.org>
parents:
653
diff
changeset
|
30 if abs(x-y) <= fuzz: |
|
675a02820d66
* os.py: _exit doesn't exist in all variations of posix
Guido van Rossum <guido@python.org>
parents:
653
diff
changeset
|
31 return 0 |
|
675a02820d66
* os.py: _exit doesn't exist in all variations of posix
Guido van Rossum <guido@python.org>
parents:
653
diff
changeset
|
32 except: |
|
675a02820d66
* os.py: _exit doesn't exist in all variations of posix
Guido van Rossum <guido@python.org>
parents:
653
diff
changeset
|
33 pass |
|
675a02820d66
* os.py: _exit doesn't exist in all variations of posix
Guido van Rossum <guido@python.org>
parents:
653
diff
changeset
|
34 elif type(x) == type(y) and type(x) in (type(()), type([])): |
|
675a02820d66
* os.py: _exit doesn't exist in all variations of posix
Guido van Rossum <guido@python.org>
parents:
653
diff
changeset
|
35 for i in range(min(len(x), len(y))): |
|
675a02820d66
* os.py: _exit doesn't exist in all variations of posix
Guido van Rossum <guido@python.org>
parents:
653
diff
changeset
|
36 outcome = fcmp(x[i], y[i]) |
|
675a02820d66
* os.py: _exit doesn't exist in all variations of posix
Guido van Rossum <guido@python.org>
parents:
653
diff
changeset
|
37 if outcome <> 0: |
|
675a02820d66
* os.py: _exit doesn't exist in all variations of posix
Guido van Rossum <guido@python.org>
parents:
653
diff
changeset
|
38 return outcome |
|
675a02820d66
* os.py: _exit doesn't exist in all variations of posix
Guido van Rossum <guido@python.org>
parents:
653
diff
changeset
|
39 return cmp(len(x), len(y)) |
|
675a02820d66
* os.py: _exit doesn't exist in all variations of posix
Guido van Rossum <guido@python.org>
parents:
653
diff
changeset
|
40 return cmp(x, y) |
|
675a02820d66
* os.py: _exit doesn't exist in all variations of posix
Guido van Rossum <guido@python.org>
parents:
653
diff
changeset
|
41 |
| 653 | 42 TESTFN = '@test' # Filename used for testing |
| 43 from os import unlink |
