summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_array.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-05-16 14:11:41 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-05-16 14:11:41 (GMT)
commitb70091a8d5014b1c5d8738c17ae801d79dd5392d (patch)
treeca8314f9372ccaff5c4f9453900b0bff0e45221a /Lib/test/test_array.py
parentf40fcb33d2e905b128daa24f7ce6f25fb5cd5d9e (diff)
downloadcpython-b70091a8d5014b1c5d8738c17ae801d79dd5392d.zip
cpython-b70091a8d5014b1c5d8738c17ae801d79dd5392d.tar.gz
cpython-b70091a8d5014b1c5d8738c17ae801d79dd5392d.tar.bz2
Issue #20014: array.array() now accepts unicode typecodes. Based on patch by
Vajrasky Kok.
Diffstat (limited to 'Lib/test/test_array.py')
-rw-r--r--Lib/test/test_array.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py
index b933cbf..7256b94 100644
--- a/Lib/test/test_array.py
+++ b/Lib/test/test_array.py
@@ -26,7 +26,17 @@ class BadConstructorTest(unittest.TestCase):
self.assertRaises(TypeError, array.array)
self.assertRaises(TypeError, array.array, spam=42)
self.assertRaises(TypeError, array.array, 'xx')
+ self.assertRaises(TypeError, array.array, '')
+ self.assertRaises(TypeError, array.array, 1)
self.assertRaises(ValueError, array.array, 'x')
+ self.assertRaises(ValueError, array.array, '\x80')
+
+ @test_support.requires_unicode
+ def test_unicode_constructor(self):
+ self.assertRaises(TypeError, array.array, u'xx')
+ self.assertRaises(TypeError, array.array, u'')
+ self.assertRaises(ValueError, array.array, u'x')
+ self.assertRaises(ValueError, array.array, u'\x80')
tests.append(BadConstructorTest)
@@ -1039,6 +1049,17 @@ class UnsignedLongTest(UnsignedNumberTest):
minitemsize = 4
tests.append(UnsignedLongTest)
+
+@test_support.requires_unicode
+class UnicodeTypecodeTest(unittest.TestCase):
+ def test_unicode_typecode(self):
+ for typecode in typecodes:
+ a = array.array(unicode(typecode))
+ self.assertEqual(a.typecode, typecode)
+ self.assertIs(type(a.typecode), str)
+tests.append(UnicodeTypecodeTest)
+
+
class FPTest(NumberTest):
example = [-42.0, 0, 42, 1e5, -1e10]
smallerexample = [-42.0, 0, 42, 1e5, -2e10]