diff options
| author | Stefan Krah <skrah@bytereef.org> | 2015-08-08 11:38:59 (GMT) |
|---|---|---|
| committer | Stefan Krah <skrah@bytereef.org> | 2015-08-08 11:38:59 (GMT) |
| commit | 5f35725fb846f2427b4bd19553d15e73747746eb (patch) | |
| tree | 28783880546e5e67ec034bafb5704193f16991f1 /Lib/test/test_memoryview.py | |
| parent | 9548f1ee3854b5c9b0f2ef05c49cf42db22f8a4f (diff) | |
| parent | 0c51595a784787d8e198af910cb6d79172ee52bb (diff) | |
| download | cpython-5f35725fb846f2427b4bd19553d15e73747746eb.zip cpython-5f35725fb846f2427b4bd19553d15e73747746eb.tar.gz cpython-5f35725fb846f2427b4bd19553d15e73747746eb.tar.bz2 | |
Merge #15944.
Diffstat (limited to 'Lib/test/test_memoryview.py')
| -rw-r--r-- | Lib/test/test_memoryview.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_memoryview.py b/Lib/test/test_memoryview.py index 6fe61a4..da01a84 100644 --- a/Lib/test/test_memoryview.py +++ b/Lib/test/test_memoryview.py @@ -492,5 +492,26 @@ class ArrayMemorySliceSliceTest(unittest.TestCase, pass +class OtherTest(unittest.TestCase): + def test_ctypes_cast(self): + # Issue 15944: Allow all source formats when casting to bytes. + ctypes = test.support.import_module("ctypes") + p6 = bytes(ctypes.c_double(0.6)) + + d = ctypes.c_double() + m = memoryview(d).cast("B") + m[:2] = p6[:2] + m[2:] = p6[2:] + self.assertEqual(d.value, 0.6) + + for format in "Bbc": + with self.subTest(format): + d = ctypes.c_double() + m = memoryview(d).cast(format) + m[:2] = memoryview(p6).cast(format)[:2] + m[2:] = memoryview(p6).cast(format)[2:] + self.assertEqual(d.value, 0.6) + + if __name__ == "__main__": unittest.main() |
