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

Function _common_shorten_repr

Lib/unittest/util.py:24–43  ·  view source on GitHub ↗
(*args)

Source from the content-addressed store, hash-verified

22 return s
23
24def _common_shorten_repr(*args):
25 args = tuple(map(safe_repr, args))
26 maxlen = max(map(len, args))
27 if maxlen <= _MAX_LENGTH:
28 return args
29
30 prefix = commonprefix(args)
31 prefixlen = len(prefix)
32
33 common_len = _MAX_LENGTH - \
34 (maxlen - prefixlen + _MIN_BEGIN_LEN + _PLACEHOLDER_LEN)
35 if common_len > _MIN_COMMON_LEN:
36 assert _MIN_BEGIN_LEN + _PLACEHOLDER_LEN + _MIN_COMMON_LEN + \
37 (maxlen - prefixlen) < _MAX_LENGTH
38 prefix = _shorten(prefix, _MIN_BEGIN_LEN, common_len)
39 return tuple(prefix + s[prefixlen:] for s in args)
40
41 prefix = _shorten(prefix, _MIN_BEGIN_LEN, _MIN_COMMON_LEN)
42 return tuple(prefix + _shorten(s[prefixlen:], _MIN_DIFF_LEN, _MIN_END_LEN)
43 for s in args)
44
45def safe_repr(obj, short=False):
46 try:

Callers 4

_baseAssertEqualMethod · 0.85
assertSequenceEqualMethod · 0.85
assertDictEqualMethod · 0.85
assertMultiLineEqualMethod · 0.85

Calls 4

commonprefixFunction · 0.90
maxFunction · 0.85
lenFunction · 0.85
_shortenFunction · 0.85

Tested by

no test coverage detected