diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2012-08-08 22:43:56 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2012-08-08 22:43:56 (GMT) |
commit | 9d512ab97f642215c16eace1705f585f41eb4162 (patch) | |
tree | 109b23ec9e82c844734a1fa856dd1ec4190a089c | |
parent | 22701e86d0ab332abc4a985109b9638c44371e42 (diff) | |
download | cpython-9d512ab97f642215c16eace1705f585f41eb4162.zip cpython-9d512ab97f642215c16eace1705f585f41eb4162.tar.gz cpython-9d512ab97f642215c16eace1705f585f41eb4162.tar.bz2 |
Issue #13072: Fix test_array for installation without the ctypes module
-rwxr-xr-x | Lib/test/test_array.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py index 974e178..eb6d77f 100755 --- a/Lib/test/test_array.py +++ b/Lib/test/test_array.py @@ -3,7 +3,6 @@ Roger E. Masse """ -import ctypes import unittest from test import support import weakref @@ -1033,6 +1032,16 @@ class UnicodeTest(StringTest): minitemsize = 2 def test_unicode(self): + try: + import ctypes + sizeof_wchar = ctypes.sizeof(ctypes.c_wchar) + except ImportError: + import sys + if sys.platform == 'win32': + sizeof_wchar = 2 + else: + sizeof_wchar = 4 + self.assertRaises(TypeError, array.array, 'b', 'foo') a = array.array('u', '\xa0\xc2\u1234') @@ -1042,7 +1051,7 @@ class UnicodeTest(StringTest): a.fromunicode('\x11abc\xff\u1234') s = a.tounicode() self.assertEqual(s, '\xa0\xc2\u1234 \x11abc\xff\u1234') - self.assertEqual(a.itemsize, ctypes.sizeof(ctypes.c_wchar)) + self.assertEqual(a.itemsize, sizeof_wchar) s = '\x00="\'a\\b\x80\xff\u0000\u0001\u1234' a = array.array('u', s) |