mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #25270: Merge from 3.5
This commit is contained in:
commit
7b4bcd2004
4 changed files with 38 additions and 6 deletions
|
@ -2542,6 +2542,26 @@ class RawUnicodeEscapeTest(unittest.TestCase):
|
|||
self.assertEqual(decode(br"\U00110000", "replace"), ("\ufffd", 10))
|
||||
|
||||
|
||||
class EscapeEncodeTest(unittest.TestCase):
|
||||
|
||||
def test_escape_encode(self):
|
||||
tests = [
|
||||
(b'', (b'', 0)),
|
||||
(b'foobar', (b'foobar', 6)),
|
||||
(b'spam\0eggs', (b'spam\\x00eggs', 9)),
|
||||
(b'a\'b', (b"a\\'b", 3)),
|
||||
(b'b\\c', (b'b\\\\c', 3)),
|
||||
(b'c\nd', (b'c\\nd', 3)),
|
||||
(b'd\re', (b'd\\re', 3)),
|
||||
(b'f\x7fg', (b'f\\x7fg', 3)),
|
||||
]
|
||||
for data, output in tests:
|
||||
with self.subTest(data=data):
|
||||
self.assertEqual(codecs.escape_encode(data), output)
|
||||
self.assertRaises(TypeError, codecs.escape_encode, 'spam')
|
||||
self.assertRaises(TypeError, codecs.escape_encode, bytearray(b'spam'))
|
||||
|
||||
|
||||
class SurrogateEscapeTest(unittest.TestCase):
|
||||
|
||||
def test_utf8(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue