Django

Code

Changeset 465

Show
Ignore:
Timestamp:
08/10/05 13:00:52 (3 years ago)
Author:
jacob
Message:

Added a custom doctest OutputChecker? that ignores differences between ints and longs in values returned from the database; refs #238

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/tests/runtests.py

    r463 r465  
    2828        self.verbosity_level = verbosity_level 
    2929        doctest.DocTestRunner.__init__(self, *args, **kwargs) 
     30        self._checker = DjangoDoctestOutputChecker() 
    3031 
    3132    def report_start(self, out, test, example): 
     
    4142        log_error(test.name, "API test raised an exception", 
    4243            "Code: %r\nLine: %s\nException: %s" % (example.source.strip(), example.lineno, tb)) 
     44             
     45class 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 
    4354 
    4455class TestRunner: