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

Unified Diff: Lib/test/test_buffer.py

Issue 15944: memoryviews and ctypes
Patch Set: Created 4 years, 6 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 | « Doc/library/stdtypes.rst ('k') | Lib/test/test_memoryview.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_buffer.py Thu Aug 06 13:17:27 2015 +0300
+++ b/Lib/test/test_buffer.py Thu Aug 06 16:47:44 2015 +0000
@@ -2559,14 +2559,17 @@
ex = ndarray(sitems, shape=[1], format=sfmt)
msrc = memoryview(ex)
for dfmt, _, _ in iter_format(1):
- if (not is_memoryview_format(sfmt) or
- not is_memoryview_format(dfmt)):
- self.assertRaises(ValueError, msrc.cast, dfmt,
- [32//dsize])
- else:
- if not is_byte_format(sfmt) and not is_byte_format(dfmt):
- self.assertRaises(TypeError, msrc.cast, dfmt,
- [32//dsize])
+ with self.subTest(sfmt=sfmt, dfmt=dfmt):
+ if not is_memoryview_format(dfmt):
+ msg = ("destination format must be a "
+ "native single character")
+ self.assertRaisesRegex(ValueError, msg,
+ msrc.cast, dfmt, [32//dsize])
+ else:
+ if not is_byte_format(sfmt) and not is_byte_format(dfmt):
+ msg = "cast between two non-byte formats"
+ self.assertRaisesRegex(TypeError, msg,
+ msrc.cast, dfmt, [32//dsize])
# invalid shape
size_h = struct.calcsize('h')
« no previous file with comments | « Doc/library/stdtypes.rst ('k') | Lib/test/test_memoryview.py » ('j') | no next file with comments »

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