mirror of
https://github.com/python/cpython.git
synced 2025-11-25 12:44:13 +00:00
Fixed memoryview constructor. It allowed arbitrary keyword arguments. The bug was found by mykhal from #python. I've also added a small test case in the new test_memoryview.py
This commit is contained in:
parent
c1bdbc316d
commit
7b6fc8e19d
2 changed files with 33 additions and 3 deletions
25
Lib/test/test_memoryview.py
Normal file
25
Lib/test/test_memoryview.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
"""Unit tests for the memoryview
|
||||
|
||||
XXX We need more tests! Some tests are in test_bytes
|
||||
"""
|
||||
|
||||
import unittest
|
||||
import test.test_support
|
||||
|
||||
class MemoryviewTest(unittest.TestCase):
|
||||
|
||||
def test_constructor(self):
|
||||
ob = b'test'
|
||||
self.assert_(memoryview(ob))
|
||||
self.assert_(memoryview(object=ob))
|
||||
self.assertRaises(TypeError, memoryview)
|
||||
self.assertRaises(TypeError, memoryview, ob, ob)
|
||||
self.assertRaises(TypeError, memoryview, argument=ob)
|
||||
self.assertRaises(TypeError, memoryview, ob, argument=True)
|
||||
|
||||
def test_main():
|
||||
test.test_support.run_unittest(MemoryviewTest)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue