summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_array.py
diff options
context:
space:
mode:
authorAlexandre Vassalotti <alexandre@peadrop.com>2013-11-30 04:47:15 (GMT)
committerAlexandre Vassalotti <alexandre@peadrop.com>2013-11-30 04:47:15 (GMT)
commit9730e335353b9cdb6f8016e27566ca7b43e42d09 (patch)
tree8e62d2e7c4ae35e5ad76c1adc9f7dd7e283b9c00 /Lib/test/test_array.py
parented7dc14d6a9598532ea535c340fce47404314c4e (diff)
downloadcpython-9730e335353b9cdb6f8016e27566ca7b43e42d09.zip
cpython-9730e335353b9cdb6f8016e27566ca7b43e42d09.tar.gz
cpython-9730e335353b9cdb6f8016e27566ca7b43e42d09.tar.bz2
Issue #3693: Fix array obscure error message when given a str.
Diffstat (limited to 'Lib/test/test_array.py')
-rwxr-xr-xLib/test/test_array.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py
index 4978c44..409d586 100755
--- a/Lib/test/test_array.py
+++ b/Lib/test/test_array.py
@@ -1027,6 +1027,18 @@ class BaseTest:
basesize = support.calcvobjsize('Pn2Pi')
support.check_sizeof(self, a, basesize)
+ def test_initialize_with_unicode(self):
+ if self.typecode != 'u':
+ with self.assertRaises(TypeError) as cm:
+ a = array.array(self.typecode, 'foo')
+ self.assertIn("cannot use a str", str(cm.exception))
+ with self.assertRaises(TypeError) as cm:
+ a = array.array(self.typecode, array.array('u', 'foo'))
+ self.assertIn("cannot use a unicode array", str(cm.exception))
+ else:
+ a = array.array(self.typecode, "foo")
+ a = array.array(self.typecode, array.array('u', 'foo'))
+
class StringTest(BaseTest):