diff options
author | Alexandre Vassalotti <alexandre@peadrop.com> | 2013-11-30 04:47:15 (GMT) |
---|---|---|
committer | Alexandre Vassalotti <alexandre@peadrop.com> | 2013-11-30 04:47:15 (GMT) |
commit | 9730e335353b9cdb6f8016e27566ca7b43e42d09 (patch) | |
tree | 8e62d2e7c4ae35e5ad76c1adc9f7dd7e283b9c00 /Lib/test/test_array.py | |
parent | ed7dc14d6a9598532ea535c340fce47404314c4e (diff) | |
download | cpython-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-x | Lib/test/test_array.py | 12 |
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): |