We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 08ea8c1 commit 1980f9bCopy full SHA for 1980f9b
1 file changed
django/test/testcases.py
@@ -63,6 +63,16 @@ def restore_transaction_methods():
63
transaction.leave_transaction_management = real_leave_transaction_management
64
transaction.managed = real_managed
65
66
+_MAX_LENGTH = 80
67
+def safe_repr(obj, short=False):
68
+ try:
69
+ result = repr(obj)
70
+ except Exception:
71
+ result = object.__repr__(obj)
72
+ if not short or len(result) < _MAX_LENGTH:
73
+ return result
74
+ return result[:_MAX_LENGTH] + ' [truncated]...'
75
+
76
class OutputChecker(doctest.OutputChecker):
77
def check_output(self, want, got, optionflags):
78
"The entry method for doctest output checking. Defers to a sequence of child checkers"
0 commit comments