Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(205327)

Side by Side Diff: Lib/test/test_codecs.py

Issue 23001: Accept mutable bytes-like objects
Patch Set: Created 4 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 import codecs 1 import codecs
2 import contextlib 2 import contextlib
3 import io 3 import io
4 import locale 4 import locale
5 import sys 5 import sys
6 import unittest 6 import unittest
7 import warnings 7 import warnings
8 import encodings 8 import encodings
9 9
10 from test import support 10 from test import support
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 if not data: 1079 if not data:
1080 break 1080 break
1081 ostream.write(data) 1081 ostream.write(data)
1082 1082
1083 got = ostream.getvalue() 1083 got = ostream.getvalue()
1084 self.assertEqual(got, unistring) 1084 self.assertEqual(got, unistring)
1085 1085
1086 class EscapeDecodeTest(unittest.TestCase): 1086 class EscapeDecodeTest(unittest.TestCase):
1087 def test_empty(self): 1087 def test_empty(self):
1088 self.assertEqual(codecs.escape_decode(b""), (b"", 0)) 1088 self.assertEqual(codecs.escape_decode(b""), (b"", 0))
1089 self.assertEqual(codecs.escape_decode(bytearray()), (b"", 0))
1089 1090
1090 def test_raw(self): 1091 def test_raw(self):
1091 decode = codecs.escape_decode 1092 decode = codecs.escape_decode
1092 for b in range(256): 1093 for b in range(256):
1093 b = bytes([b]) 1094 b = bytes([b])
1094 if b != b'\\': 1095 if b != b'\\':
1095 self.assertEqual(decode(b + b'0'), (b + b'0', 2)) 1096 self.assertEqual(decode(b + b'0'), (b + b'0', 2))
1096 1097
1097 def test_escape(self): 1098 def test_escape(self):
1098 decode = codecs.escape_decode 1099 decode = codecs.escape_decode
(...skipping 1926 matching lines...) Expand 10 before | Expand all | Expand 10 after
3025 self.assertEqual(decoded, ('\u9a3e\u9a3e', 4)) 3026 self.assertEqual(decoded, ('\u9a3e\u9a3e', 4))
3026 3027
3027 decoded = codecs.code_page_decode(932, 3028 decoded = codecs.code_page_decode(932,
3028 b'abc', 'strict', 3029 b'abc', 'strict',
3029 False) 3030 False)
3030 self.assertEqual(decoded, ('abc', 3)) 3031 self.assertEqual(decoded, ('abc', 3))
3031 3032
3032 3033
3033 if __name__ == "__main__": 3034 if __name__ == "__main__":
3034 unittest.main() 3035 unittest.main()
OLDNEW

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+