From 6604017559833e5d4fcabd9320db64c8c6399eed Mon Sep 17 00:00:00 2001 From: Meador Inge Date: Tue, 20 Sep 2011 19:55:51 -0500 Subject: Issue #1172711: Add 'long long' support to the array module. Initial patch by Oren Tirosh and Hirokazu Yamamoto. --- Lib/test/test_array.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'Lib/test/test_array.py') diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py index 5190c357ea..604dcdf8a5 100755 --- a/Lib/test/test_array.py +++ b/Lib/test/test_array.py @@ -16,6 +16,13 @@ import warnings import array from array import _array_reconstructor as array_reconstructor +try: + # Try to determine availability of long long independently + # of the array module under test + struct.calcsize('@q') + have_long_long = True +except struct.error: + have_long_long = False class ArraySubclass(array.array): pass @@ -26,6 +33,8 @@ class ArraySubclassWithKwargs(array.array): tests = [] # list to accumulate all tests typecodes = "ubBhHiIlLfd" +if have_long_long: + typecodes += 'qQ' class BadConstructorTest(unittest.TestCase): @@ -1205,6 +1214,18 @@ class UnsignedLongTest(UnsignedNumberTest): minitemsize = 4 tests.append(UnsignedLongTest) +@unittest.skipIf(not have_long_long, 'need long long support') +class LongLongTest(SignedNumberTest): + typecode = 'q' + minitemsize = 8 +tests.append(LongLongTest) + +@unittest.skipIf(not have_long_long, 'need long long support') +class UnsignedLongLongTest(UnsignedNumberTest): + typecode = 'Q' + minitemsize = 8 +tests.append(UnsignedLongLongTest) + class FPTest(NumberTest): example = [-42.0, 0, 42, 1e5, -1e10] smallerexample = [-42.0, 0, 42, 1e5, -2e10] -- cgit v1.2.1 From 8817877ab4feda8f648dc1425916b958c4c842e3 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 30 Sep 2011 00:51:10 +0200 Subject: array module uses the new Unicode API * Use Py_UCS4* buffer instead of Py_UNICODE* * Use "I" or "L" format, instead of "u" format --- Lib/test/test_array.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'Lib/test/test_array.py') diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py index 604dcdf8a5..fc17b428ff 100755 --- a/Lib/test/test_array.py +++ b/Lib/test/test_array.py @@ -218,10 +218,14 @@ class BaseTest(unittest.TestCase): self.assertEqual(bi[1], len(a)) def test_byteswap(self): - a = array.array(self.typecode, self.example) + if self.typecode == 'u': + example = '\U00100100' + else: + example = self.example + a = array.array(self.typecode, example) self.assertRaises(TypeError, a.byteswap, 42) if a.itemsize in (1, 2, 4, 8): - b = array.array(self.typecode, self.example) + b = array.array(self.typecode, example) b.byteswap() if a.itemsize==1: self.assertEqual(a, b) -- cgit v1.2.1 From 0a7de8c1eb413029b0bf04721d4b5938820d08a0 Mon Sep 17 00:00:00 2001 From: Ezio Melotti Date: Tue, 25 Oct 2011 10:05:34 +0300 Subject: Remove mention of narrow/wide builds and update array doc, add a test. --- Lib/test/test_array.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Lib/test/test_array.py') diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py index fc17b428ff..434e495f86 100755 --- a/Lib/test/test_array.py +++ b/Lib/test/test_array.py @@ -1015,7 +1015,7 @@ class UnicodeTest(StringTest): smallerexample = '\x01\u263a\x00\ufefe' biggerexample = '\x01\u263a\x01\ufeff' outside = str('\x33') - minitemsize = 2 + minitemsize = 4 def test_unicode(self): self.assertRaises(TypeError, array.array, 'b', 'foo') @@ -1027,6 +1027,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, 4) s = '\x00="\'a\\b\x80\xff\u0000\u0001\u1234' a = array.array('u', s) -- cgit v1.2.1 From 85f68bdee6df6f2426de597a97f9c33c7066570f Mon Sep 17 00:00:00 2001 From: Kristj?n Valur J?nsson Date: Tue, 3 Apr 2012 10:49:41 +0000 Subject: Issue #14288: Serialization support for builtin iterators. --- Lib/test/test_array.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'Lib/test/test_array.py') diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py index 434e495f86..93853396c9 100755 --- a/Lib/test/test_array.py +++ b/Lib/test/test_array.py @@ -285,6 +285,20 @@ class BaseTest(unittest.TestCase): self.assertEqual(a.x, b.x) self.assertEqual(type(a), type(b)) + def test_iterator_pickle(self): + data = array.array(self.typecode, self.example) + orgit = iter(data) + d = pickle.dumps(orgit) + it = pickle.loads(d) + self.assertEqual(type(orgit), type(it)) + self.assertEqual(list(it), list(data)) + + if len(data): + it = pickle.loads(d) + next(it) + d = pickle.dumps(it) + self.assertEqual(list(it), list(data)[1:]) + def test_insert(self): a = array.array(self.typecode, self.example) a.insert(0, self.example[0]) -- cgit v1.2.1