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

Method test_safe_repr

Lib/test/test_unittest/test_util.py:6–17  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4
5class TestUtil(unittest.TestCase):
6 def test_safe_repr(self):
7 class RaisingRepr:
8 def __repr__(self):
9 raise ValueError("Invalid repr()")
10
11 class LongRepr:
12 def __repr__(self):
13 return 'x' * 100
14
15 safe_repr(RaisingRepr())
16 self.assertEqual(safe_repr('foo'), "'foo'")
17 self.assertEqual(safe_repr(LongRepr(), short=True), 'x'*80 + ' [truncated]...')
18
19 def test_sorted_list_difference(self):
20 self.assertEqual(sorted_list_difference([], []), ([], []))

Callers

nothing calls this directly

Calls 4

safe_reprFunction · 0.90
RaisingReprClass · 0.85
LongReprClass · 0.85
assertEqualMethod · 0.45

Tested by

no test coverage detected