Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
  • Loading branch information...
commit 3a1ae2164b79506b58cacec15a1afa9b28f0349a 1 parent 254f318
Jacob Kaplan-Moss authored August 10, 2005

Showing 1 changed file with 11 additions and 0 deletions. Show diff stats Hide diff stats

  1. 11  tests/runtests.py
11  tests/runtests.py
@@ -27,6 +27,7 @@ class DjangoDoctestRunner(doctest.DocTestRunner):
27 27
     def __init__(self, verbosity_level, *args, **kwargs):
28 28
         self.verbosity_level = verbosity_level
29 29
         doctest.DocTestRunner.__init__(self, *args, **kwargs)
  30
+        self._checker = DjangoDoctestOutputChecker()
30 31
 
31 32
     def report_start(self, out, test, example):
32 33
         if self.verbosity_level > 1:
@@ -40,6 +41,16 @@ def report_unexpected_exception(self, out, test, example, exc_info):
40 41
         tb = ''.join(traceback.format_exception(*exc_info)[1:])
41 42
         log_error(test.name, "API test raised an exception",
42 43
             "Code: %r\nLine: %s\nException: %s" % (example.source.strip(), example.lineno, tb))
  44
+            
  45
+class DjangoDoctestOutputChecker(doctest.OutputChecker):
  46
+    def check_output(self, want, got, optionflags):
  47
+        ok = doctest.OutputChecker.check_output(self, want, got, optionflags)
  48
+        if not ok and (want.strip().endswith("L") or got.strip().endswith("L")):
  49
+            try:
  50
+                return long(want.strip()) == long(got.strip())
  51
+            except ValueError:
  52
+                return False
  53
+        return ok
43 54
 
44 55
 class TestRunner:
45 56
     def __init__(self, verbosity_level=0):

0 notes on commit 3a1ae21

Please sign in to comment.
Something went wrong with that request. Please try again.