예제 #1
0
 def test_unicode_escape(self):
     from _codecs import unicode_escape_encode, unicode_escape_decode
     assert unicode_escape_encode(u'abc') == (
         u'abc'.encode('unicode_escape'), 3)
     assert unicode_escape_decode('abc') == (
         u'abc'.decode('unicode_escape'), 3)
     assert unicode_escape_decode('\\x61\\x62\\x63') == (u'abc', 12)
예제 #2
0
파일: test_codecs.py 프로젝트: Qointum/pypy
 def test_unicode_escape(self):
     import _codecs
     assert '\\'.encode('unicode-escape') == b'\\\\'
     assert b'\\\\'.decode('unicode-escape') == '\\'
     assert '\ud801'.encode('unicode-escape') == b'\\ud801'
     assert '\u0013'.encode('unicode-escape') == b'\\x13'
     assert _codecs.unicode_escape_decode(r"\u1234") == ("\u1234", 6)
예제 #3
0
 def test_unicode_escape(self):
     import _codecs
     assert '\\'.encode('unicode-escape') == b'\\\\'
     assert b'\\\\'.decode('unicode-escape') == '\\'
     assert '\ud801'.encode('unicode-escape') == b'\\ud801'
     assert '\u0013'.encode('unicode-escape') == b'\\x13'
     assert _codecs.unicode_escape_decode(r"\u1234") == ("\u1234", 6)
예제 #4
0
 def test_decode_bytearray(self):
     import _codecs
     b = bytearray()
     assert _codecs.ascii_decode(b) == (u'', 0)
     assert _codecs.latin_1_decode(b) == (u'', 0)
     assert _codecs.utf_7_decode(b) == (u'', 0)
     assert _codecs.utf_8_decode(b) == (u'', 0)
     assert _codecs.utf_16_be_decode(b) == (u'', 0)
     assert _codecs.utf_16_decode(b) == (u'', 0)
     assert _codecs.utf_16_le_decode(b) == (u'', 0)
     assert _codecs.utf_16_ex_decode(b) == (u'', 0, 0)
     assert _codecs.utf_32_decode(b) == (u'', 0)
     assert _codecs.utf_32_be_decode(b) == (u'', 0)
     assert _codecs.utf_32_le_decode(b) == (u'', 0)
     assert _codecs.utf_32_ex_decode(b) == (u'', 0, 0)
     assert _codecs.charmap_decode(b) == (u'', 0)
     assert _codecs.unicode_escape_decode(b) == (u'', 0)
     assert _codecs.raw_unicode_escape_decode(b) == (u'', 0)
     assert _codecs.unicode_internal_decode(b) == (u'', 0)
예제 #5
0
파일: test_codecs.py 프로젝트: Qointum/pypy
 def test_decode_bytearray(self):
     import _codecs
     b = bytearray()
     assert _codecs.ascii_decode(b) == (u'', 0)
     assert _codecs.latin_1_decode(b) == (u'', 0)
     assert _codecs.utf_7_decode(b) == (u'', 0)
     assert _codecs.utf_8_decode(b) == (u'', 0)
     assert _codecs.utf_16_be_decode(b) == (u'', 0)
     assert _codecs.utf_16_decode(b) == (u'', 0)
     assert _codecs.utf_16_le_decode(b) == (u'', 0)
     assert _codecs.utf_16_ex_decode(b) == (u'', 0, 0)
     assert _codecs.utf_32_decode(b) == (u'', 0)
     assert _codecs.utf_32_be_decode(b) == (u'', 0)
     assert _codecs.utf_32_le_decode(b) == (u'', 0)
     assert _codecs.utf_32_ex_decode(b) == (u'', 0, 0)
     assert _codecs.charmap_decode(b) == (u'', 0)
     assert _codecs.unicode_escape_decode(b) == (u'', 0)
     assert _codecs.raw_unicode_escape_decode(b) == (u'', 0)
     assert _codecs.unicode_internal_decode(b) == (u'', 0)
예제 #6
0
 def test_escape_decode_escaped_newline(self):
     import _codecs
     s = b'\\\n'
     decoded = _codecs.unicode_escape_decode(s)[0]
     assert decoded == ''
예제 #7
0
 def test_escape_decode_escaped_newline(self):
     import _codecs
     s = '\\\n'
     decoded = _codecs.unicode_escape_decode(s)[0]
     assert decoded == ''
예제 #8
0
 def test_unicode_escape(self):
     from _codecs import unicode_escape_encode, unicode_escape_decode
     assert unicode_escape_encode(u'abc') == (u'abc'.encode('unicode_escape'), 3)
     assert unicode_escape_decode('abc') == (u'abc'.decode('unicode_escape'), 3)
     assert unicode_escape_decode('\\x61\\x62\\x63') == (u'abc', 12)
예제 #9
0
    def test_unicode_escape(self):
        from _codecs import unicode_escape_encode, unicode_escape_decode

        assert unicode_escape_encode(u"abc") == (u"abc".encode("unicode_escape"), 3)
        assert unicode_escape_decode("abc") == (u"abc".decode("unicode_escape"), 3)
        assert unicode_escape_decode("\\x61\\x62\\x63") == (u"abc", 12)