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'))
def repr_type(value): """Convert a text or bytes object into the appropriate return type for the __repr__ method.""" return compatible_repr(lambda: value)()
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'))
def _create_generic_str(target_type): return compatible_repr(lambda self: str(target_type(self)))