MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / test_no_repr

Function test_no_repr

tests_python/test_safe_repr.py:647–676  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

645
646
647def test_no_repr():
648 class MyBytes(object):
649 def __init__(self, contents):
650 self.contents = contents
651 self.errored = None
652
653 def __iter__(self):
654 return iter(self.contents)
655
656 def decode(self, encoding):
657 self.errored = "decode called"
658 raise RuntimeError("Should not be called.")
659
660 def __repr__(self):
661 self.errored = "__repr__ called"
662 raise RuntimeError("Should not be called.")
663
664 def __getitem__(self, *args):
665 return self.contents.__getitem__(*args)
666
667 def __len__(self):
668 return len(self.contents)
669
670 safe_repr = SafeRepr()
671 safe_repr.string_types = (MyBytes,)
672 safe_repr.bytes = MyBytes
673 obj = b"f" * (safe_repr.maxstring_outer * 10)
674 my_bytes = MyBytes(obj)
675 raw_value_repr = safe_repr(my_bytes)
676 assert not my_bytes.errored

Callers

nothing calls this directly

Calls 2

SafeReprClass · 0.90
MyBytesClass · 0.85

Tested by

no test coverage detected