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

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

Issue 23001: Accept mutable bytes-like objects
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « no previous file | Lib/test/test_fcntl.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 if not data: 1075 if not data:
1076 break 1076 break
1077 ostream.write(data) 1077 ostream.write(data)
1078 1078
1079 got = ostream.getvalue() 1079 got = ostream.getvalue()
1080 self.assertEqual(got, unistring) 1080 self.assertEqual(got, unistring)
1081 1081
1082 class EscapeDecodeTest(unittest.TestCase): 1082 class EscapeDecodeTest(unittest.TestCase):
1083 def test_empty(self): 1083 def test_empty(self):
1084 self.assertEqual(codecs.escape_decode(b""), (b"", 0)) 1084 self.assertEqual(codecs.escape_decode(b""), (b"", 0))
1085 self.assertEqual(codecs.escape_decode(bytearray()), (b"", 0))
1085 1086
1086 def test_raw(self): 1087 def test_raw(self):
1087 decode = codecs.escape_decode 1088 decode = codecs.escape_decode
1088 for b in range(256): 1089 for b in range(256):
1089 b = bytes([b]) 1090 b = bytes([b])
1090 if b != b'\\': 1091 if b != b'\\':
1091 self.assertEqual(decode(b + b'0'), (b + b'0', 2)) 1092 self.assertEqual(decode(b + b'0'), (b + b'0', 2))
1092 1093
1093 def test_escape(self): 1094 def test_escape(self):
1094 decode = codecs.escape_decode 1095 decode = codecs.escape_decode
(...skipping 1823 matching lines...) Expand 10 before | Expand all | Expand 10 after
2918 self.assertEqual(decoded, ('\u9a3e\u9a3e', 4)) 2919 self.assertEqual(decoded, ('\u9a3e\u9a3e', 4))
2919 2920
2920 decoded = codecs.code_page_decode(932, 2921 decoded = codecs.code_page_decode(932,
2921 b'abc', 'strict', 2922 b'abc', 'strict',
2922 False) 2923 False)
2923 self.assertEqual(decoded, ('abc', 3)) 2924 self.assertEqual(decoded, ('abc', 3))
2924 2925
2925 2926
2926 if __name__ == "__main__": 2927 if __name__ == "__main__":
2927 unittest.main() 2928 unittest.main()
OLDNEW
« no previous file with comments | « no previous file | Lib/test/test_fcntl.py » ('j') | no next file with comments »

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