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

Unified Diff: Lib/test/test_codecs.py

Issue 17839: base64 module should use memoryview
Patch Set: Created 6 years, 4 months ago
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/test/test_base64.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_codecs.py Thu May 23 20:25:09 2013 +1000
+++ b/Lib/test/test_codecs.py Thu May 23 21:29:00 2013 +1000
@@ -2285,6 +2285,24 @@
sout = reader.readline()
self.assertEqual(sout, b"\x80")
+ def test_buffer_api_usage(self):
+ # We check all the transform codecs accept memoryview input
+ # for encoding and decoding
+ # and also that they roundtrip correctly
+ original = b"12345\x80"
+ for encoding in bytes_transform_encodings:
+ data = original
+ view = memoryview(data)
+ data = codecs.encode(data, encoding)
+ view_encoded = codecs.encode(view, encoding)
+ self.assertEqual(view_encoded, data)
+ view = memoryview(data)
+ data = codecs.decode(data, encoding)
+ self.assertEqual(data, original)
+ view_decoded = codecs.decode(view, encoding)
+ self.assertEqual(view_decoded, data)
+
+
@unittest.skipUnless(sys.platform == 'win32',
'code pages are specific to Windows')
« no previous file with comments | « Lib/test/test_base64.py ('k') | no next file » | no next file with comments »

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