summaryrefslogtreecommitdiff
path: root/Lib/test/test_array.py
diff options
context:
space:
mode:
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>2011-01-11 22:16:24 +0000
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>2011-01-11 22:16:24 +0000
commit830c85d0bacc2366af8b75becca021e00e976298 (patch)
tree63f2112cfea98ae26524f175061dca91cbd67c06 /Lib/test/test_array.py
parentd501dde89d1ced7c5a96c727511b94d1b8d3a45c (diff)
downloadcpython-git-830c85d0bacc2366af8b75becca021e00e976298.tar.gz
Merged revisions 87942 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r87942 | alexander.belopolsky | 2011-01-11 16:44:00 -0500 (Tue, 11 Jan 2011) | 3 lines Issue #5109: array.array constructor will now use fast code when initial data is provided in an array object with correct type. ........
Diffstat (limited to 'Lib/test/test_array.py')
-rwxr-xr-xLib/test/test_array.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py
index 4d56f54559..d92205baa9 100755
--- a/Lib/test/test_array.py
+++ b/Lib/test/test_array.py
@@ -239,6 +239,11 @@ class BaseTest(unittest.TestCase):
if a.itemsize>1:
self.assertRaises(ValueError, b.fromstring, "x")
+ def test_fromarray(self):
+ a = array.array(self.typecode, self.example)
+ b = array.array(self.typecode, a)
+ self.assertEqual(a, b)
+
def test_repr(self):
a = array.array(self.typecode, 2*self.example)
self.assertEqual(a, eval(repr(a), {"array": array.array}))
@@ -958,6 +963,11 @@ class NumberTest(BaseTest):
self.assertRaises(AttributeError, setattr, a, "color", "blue")
+ def test_frombytearray(self):
+ a = array.array('b', range(10))
+ b = array.array(self.typecode, a)
+ self.assertEqual(a, b)
+
class SignedNumberTest(NumberTest):
example = [-1, 0, 1, 42, 0x7f]
smallerexample = [-1, 0, 1, 42, 0x7e]