Checkout prior commit of _doctest.py
This commit is contained in:
parent
8d7ddec17c
commit
e459893e34
|
@ -898,7 +898,7 @@ class DocTestFinder:
|
||||||
elif hasattr(object, '__module__'):
|
elif hasattr(object, '__module__'):
|
||||||
return module.__name__ == object.__module__
|
return module.__name__ == object.__module__
|
||||||
elif isinstance(object, property):
|
elif isinstance(object, property):
|
||||||
return True # [XX] no way not be sure.
|
return True # [XX] no way not be sure.
|
||||||
else:
|
else:
|
||||||
raise ValueError("object must be a class or function")
|
raise ValueError("object must be a class or function")
|
||||||
|
|
||||||
|
@ -1221,7 +1221,7 @@ class DocTestRunner:
|
||||||
# to modify them).
|
# to modify them).
|
||||||
original_optionflags = self.optionflags
|
original_optionflags = self.optionflags
|
||||||
|
|
||||||
SUCCESS, FAILURE, BOOM = range(3) # `outcome` state
|
SUCCESS, FAILURE, BOOM = range(3) # `outcome` state
|
||||||
|
|
||||||
check = self._checker.check_output
|
check = self._checker.check_output
|
||||||
|
|
||||||
|
@ -1274,7 +1274,7 @@ class DocTestRunner:
|
||||||
# Strip b"" and u"" prefixes from the repr and expected output
|
# Strip b"" and u"" prefixes from the repr and expected output
|
||||||
# TODO: better way of stripping the prefixes?
|
# TODO: better way of stripping the prefixes?
|
||||||
expected = example.want
|
expected = example.want
|
||||||
expected = expected.strip() # be wary of newlines
|
expected = expected.strip() # be wary of newlines
|
||||||
s = s.replace("u", "")
|
s = s.replace("u", "")
|
||||||
s = s.replace("b", "")
|
s = s.replace("b", "")
|
||||||
expected = expected.replace("u", "")
|
expected = expected.replace("u", "")
|
||||||
|
@ -1288,7 +1288,7 @@ class DocTestRunner:
|
||||||
lines.append(s)
|
lines.append(s)
|
||||||
|
|
||||||
# let them match
|
# let them match
|
||||||
if s == expected: # be wary of false positives here
|
if s == expected: # be wary of false positives here
|
||||||
# they should be the same, print expected value
|
# they should be the same, print expected value
|
||||||
sys.stdout.write("%s\n" % example.want.strip())
|
sys.stdout.write("%s\n" % example.want.strip())
|
||||||
|
|
||||||
|
@ -1314,13 +1314,13 @@ class DocTestRunner:
|
||||||
# Don't blink! This is where the user's code gets run.
|
# Don't blink! This is where the user's code gets run.
|
||||||
six.exec_(compile(example.source, filename, "single",
|
six.exec_(compile(example.source, filename, "single",
|
||||||
compileflags, 1), test.globs)
|
compileflags, 1), test.globs)
|
||||||
self.debugger.set_continue() # ==== Example Finished ====
|
self.debugger.set_continue() # ==== Example Finished ====
|
||||||
exception = None
|
exception = None
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
raise
|
raise
|
||||||
except:
|
except:
|
||||||
exception = sys.exc_info()
|
exception = sys.exc_info()
|
||||||
self.debugger.set_continue() # ==== Example Finished ====
|
self.debugger.set_continue() # ==== Example Finished ====
|
||||||
finally:
|
finally:
|
||||||
# restore the original displayhook
|
# restore the original displayhook
|
||||||
sys.displayhook = original_displayhook
|
sys.displayhook = original_displayhook
|
||||||
|
@ -1647,11 +1647,11 @@ class OutputChecker:
|
||||||
# Use difflib to find their differences.
|
# Use difflib to find their differences.
|
||||||
if optionflags & REPORT_UDIFF:
|
if optionflags & REPORT_UDIFF:
|
||||||
diff = difflib.unified_diff(want_lines, got_lines, n=2)
|
diff = difflib.unified_diff(want_lines, got_lines, n=2)
|
||||||
diff = list(diff)[2:] # strip the diff header
|
diff = list(diff)[2:] # strip the diff header
|
||||||
kind = 'unified diff with -expected +actual'
|
kind = 'unified diff with -expected +actual'
|
||||||
elif optionflags & REPORT_CDIFF:
|
elif optionflags & REPORT_CDIFF:
|
||||||
diff = difflib.context_diff(want_lines, got_lines, n=2)
|
diff = difflib.context_diff(want_lines, got_lines, n=2)
|
||||||
diff = list(diff)[2:] # strip the diff header
|
diff = list(diff)[2:] # strip the diff header
|
||||||
kind = 'context diff with expected followed by actual'
|
kind = 'context diff with expected followed by actual'
|
||||||
elif optionflags & REPORT_NDIFF:
|
elif optionflags & REPORT_NDIFF:
|
||||||
engine = difflib.Differ(charjunk=difflib.IS_CHARACTER_JUNK)
|
engine = difflib.Differ(charjunk=difflib.IS_CHARACTER_JUNK)
|
||||||
|
|
Loading…
Reference in New Issue