Changeset 2035
- Timestamp:
- 01/17/06 11:57:27 (3 years ago)
- Files:
-
- django/branches/magic-removal/tests/runtests.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/magic-removal/tests/runtests.py
r1845 r2035 1 1 #!/usr/bin/env python 2 2 3 import os, sys, time, traceback3 import os, re, sys, time, traceback 4 4 5 5 # doctest is included in the same package as this module, because this testing … … 44 44 "Code: %r\nLine: %s\nException: %s" % (example.source.strip(), example.lineno, tb)) 45 45 46 normalize_long_ints = lambda s: re.sub(r'(?<![\w])(\d+)L(?![\w])', '\\1', s) 47 46 48 class DjangoDoctestOutputChecker(doctest.OutputChecker): 47 49 def check_output(self, want, got, optionflags): 48 50 ok = doctest.OutputChecker.check_output(self, want, got, optionflags) 49 if not ok and (want.strip().endswith("L") or got.strip().endswith("L")): 50 try: 51 return long(want.strip()) == long(got.strip()) 52 except ValueError: 53 return False 51 52 # Doctest does an exact string comparison of output, which means long 53 # integers aren't equal to normal integers ("22L" vs. "22"). The 54 # following code normalizes long integers so that they equal normal 55 # integers. 56 if not ok: 57 return normalize_long_ints(want) == normalize_long_ints(got) 54 58 return ok 55 59
