MCPcopy Index your code
hub / github.com/python/cpython / safe_repr

Function safe_repr

Lib/unittest/util.py:54–61  ·  view source on GitHub ↗
(obj, short=False)

Source from the content-addressed store, hash-verified

52 for s in args)
53
54def safe_repr(obj, short=False):
55 try:
56 result = repr(obj)
57 except Exception:
58 result = object.__repr__(obj)
59 if not short or len(result) < _MAX_LENGTH:
60 return result
61 return result[:_MAX_LENGTH] + ' [truncated]...'
62
63def strclass(cls):
64 return "%s.%s" % (cls.__module__, cls.__qualname__)

Callers 15

assert_has_callsMethod · 0.90
_calls_reprMethod · 0.90
test_safe_reprMethod · 0.90
assertFalseMethod · 0.85
assertTrueMethod · 0.85
_formatMessageMethod · 0.85
assertNotEqualMethod · 0.85
assertAlmostEqualMethod · 0.85
assertNotAlmostEqualMethod · 0.85
assertSequenceEqualMethod · 0.85
assertInMethod · 0.85
assertNotInMethod · 0.85

Calls 1

__repr__Method · 0.45

Tested by 1

test_safe_reprMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…