diff options
author | Martin Panter <vadmium+py@gmail.com> | 2016-11-20 07:58:35 +0000 |
---|---|---|
committer | Martin Panter <vadmium+py@gmail.com> | 2016-11-20 07:58:35 +0000 |
commit | f42342d83e2d565b704b84954c3d9c4604d584f0 (patch) | |
tree | 394cb6b25dfd972443e44d0603ab65c36d769601 /Lib/ctypes/test/test_frombuffer.py | |
parent | b045cd28da342ec5f6031f6251707293e2f58aac (diff) | |
download | cpython-f42342d83e2d565b704b84954c3d9c4604d584f0.tar.gz |
Issue #25659: Change assert to TypeError in from_buffer/_copy()
Based on suggestion by Eryk Sun.
Diffstat (limited to 'Lib/ctypes/test/test_frombuffer.py')
-rw-r--r-- | Lib/ctypes/test/test_frombuffer.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/ctypes/test/test_frombuffer.py b/Lib/ctypes/test/test_frombuffer.py index 29c5a19328..7ab38f1b03 100644 --- a/Lib/ctypes/test/test_frombuffer.py +++ b/Lib/ctypes/test/test_frombuffer.py @@ -120,5 +120,13 @@ class Test(unittest.TestCase): with self.assertRaises(ValueError): (c_int * 1).from_buffer_copy(a, 16 * sizeof(c_int)) + def test_abstract(self): + self.assertRaises(TypeError, Array.from_buffer, bytearray(10)) + self.assertRaises(TypeError, Structure.from_buffer, bytearray(10)) + self.assertRaises(TypeError, Union.from_buffer, bytearray(10)) + self.assertRaises(TypeError, Array.from_buffer_copy, b"123") + self.assertRaises(TypeError, Structure.from_buffer_copy, b"123") + self.assertRaises(TypeError, Union.from_buffer_copy, b"123") + if __name__ == '__main__': unittest.main() |