def test_bytes_max_length(self): x = compat.b('\xd7\xd7\xd7\xd7\xd7\xd7') result = transform(x, string_max_length=1) if compat.PY3: assert result == "b'\\xd7'" else: assert result == "'\\xd7'"
def test_recurse_exception(self): class NonAsciiRepr(object): def __repr__(self): return compat.b('中文') x = [NonAsciiRepr()] result = transform(x, max_depth=1) self.assertEqual(json.dumps(result), compat.b('["<class \'tests.utils.encoding.tests.NonAsciiRepr\'>"]'))
def test_recurse_exception(self): class NonAsciiRepr(object): def __repr__(self): return compat.b('中文') x = [NonAsciiRepr()] result = transform(x, max_depth=1) self.assertEqual( json.dumps(result), compat.b( '["<class \'tests.utils.encoding.tests.NonAsciiRepr\'>"]'))
def test_bad_string(self): x = compat.b('The following character causes problems: \xd4') result = transform(x) assert result == compat.b("'The following character causes problems: \\xd4'")
def test_string_in_python2(self): # 'רונית מגן' x = compat.b('hello world') result = transform(x) assert result == "'hello world'"
def __repr__(self): return compat.b('中文')
def test_incorrect_unicode(self): x = compat.b('רונית מגן') result = transform(x) assert result == compat.b("'רונית מגן'")
def test_bad_string(self): x = compat.b('The following character causes problems: \xd4') result = transform(x) assert result == compat.b( "'The following character causes problems: \\xd4'")