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

Method test_safe_repr

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

Source from the content-addressed store, hash-verified

8
9class TestUtil(unittest.TestCase):
10 def test_safe_repr(self):
11 class RaisingRepr:
12 def __repr__(self):
13 raise ValueError("Invalid repr()")
14
15 class LongRepr:
16 def __repr__(self):
17 return 'x' * 100
18
19 safe_repr(RaisingRepr())
20 self.assertEqual(safe_repr('foo'), "'foo'")
21 self.assertEqual(safe_repr(LongRepr(), short=True), 'x'*80 + ' [truncated]...')
22
23 def test_sorted_list_difference(self):
24 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