Exemplo n.º 1
0
 def test_py3_bytes_are_returned_as_unicode(self):
     repr_fn = compatible_repr(lambda: b"bytes")
     result = repr_fn()
     self.assertThat(result, IsInstance(str))
     self.assertThat(result, Equals('bytes'))
Exemplo n.º 2
0
def repr_type(value):
    """Convert a text or bytes object into the appropriate return type for
    the __repr__ method."""
    return compatible_repr(lambda: value)()
Exemplo n.º 3
0
 def test_py3_unicode_is_untouched(self):
     repr_fn = compatible_repr(lambda: "unicode")
     result = repr_fn()
     self.assertThat(result, IsInstance(str))
     self.assertThat(result, Equals('unicode'))
Exemplo n.º 4
0
def _create_generic_str(target_type):
    return compatible_repr(lambda self: str(target_type(self)))