summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2005-08-10 18:00:52 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2005-08-10 18:00:52 +0000
commit3a1ae2164b79506b58cacec15a1afa9b28f0349a (patch)
tree66ef0e2fcdd2a7a7b5ee29d27558bfcc99e1f609
parent254f31819bb47eb23ea4f163154a55e80e2478a9 (diff)
Added a custom doctest OutputChecker that ignores differences between ints and longs in values returned from the database; refs #238
git-svn-id: http://code.djangoproject.com/svn/django/trunk@465 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rwxr-xr-xtests/runtests.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/runtests.py b/tests/runtests.py
index a12ad18edd..80fe352fc8 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -27,6 +27,7 @@ class DjangoDoctestRunner(doctest.DocTestRunner):
def __init__(self, verbosity_level, *args, **kwargs):
self.verbosity_level = verbosity_level
doctest.DocTestRunner.__init__(self, *args, **kwargs)
+ self._checker = DjangoDoctestOutputChecker()
def report_start(self, out, test, example):
if self.verbosity_level > 1:
@@ -40,6 +41,16 @@ class DjangoDoctestRunner(doctest.DocTestRunner):
tb = ''.join(traceback.format_exception(*exc_info)[1:])
log_error(test.name, "API test raised an exception",
"Code: %r\nLine: %s\nException: %s" % (example.source.strip(), example.lineno, tb))
+
+class DjangoDoctestOutputChecker(doctest.OutputChecker):
+ def check_output(self, want, got, optionflags):
+ ok = doctest.OutputChecker.check_output(self, want, got, optionflags)
+ if not ok and (want.strip().endswith("L") or got.strip().endswith("L")):
+ try:
+ return long(want.strip()) == long(got.strip())
+ except ValueError:
+ return False
+ return ok
class TestRunner:
def __init__(self, verbosity_level=0):