Esempio n. 1
0
 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'"
Esempio n. 2
0
 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'"
Esempio n. 3
0
    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\'>"]'))
Esempio n. 4
0
    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\'>"]'))
Esempio n. 5
0
    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'")
Esempio n. 6
0
    def test_string_in_python2(self):
        # 'רונית מגן'
        x = compat.b('hello world')

        result = transform(x)
        assert result == "'hello world'"
Esempio n. 7
0
 def __repr__(self):
     return compat.b('中文')
Esempio n. 8
0
    def test_incorrect_unicode(self):
        x = compat.b('רונית מגן')
        result = transform(x)

        assert result == compat.b("'רונית מגן'")
Esempio n. 9
0
    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'")
Esempio n. 10
0
    def test_string_in_python2(self):
        # 'רונית מגן'
        x = compat.b('hello world')

        result = transform(x)
        assert result == "'hello world'"
Esempio n. 11
0
 def __repr__(self):
     return compat.b('中文')
Esempio n. 12
0
    def test_incorrect_unicode(self):
        x = compat.b('רונית מגן')
        result = transform(x)

        assert result == compat.b("'רונית מגן'")