MCPcopy Index your code
hub / github.com/RustPython/RustPython / safe_repr

Function safe_repr

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

Source from the content-addressed store, hash-verified

43 for s in args)
44
45def safe_repr(obj, short=False):
46 try:
47 result = repr(obj)
48 except Exception:
49 result = object.__repr__(obj)
50 if not short or len(result) < _MAX_LENGTH:
51 return result
52 return result[:_MAX_LENGTH] + ' [truncated]...'
53
54def strclass(cls):
55 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 3

reprFunction · 0.85
lenFunction · 0.85
__repr__Method · 0.45

Tested by 1

test_safe_reprMethod · 0.72