diff options
author | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2011-01-11 21:44:00 (GMT) |
---|---|---|
committer | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2011-01-11 21:44:00 (GMT) |
commit | ef4a03fffec57617e4c3396046960f49c463f5df (patch) | |
tree | 8e989318d3d91cd44cbeb7b2f9d0ebba921706e9 /Lib/test/test_array.py | |
parent | cf8a382c942ab84f93a95d85758ca2e438346399 (diff) | |
download | cpython-ef4a03fffec57617e4c3396046960f49c463f5df.zip cpython-ef4a03fffec57617e4c3396046960f49c463f5df.tar.gz cpython-ef4a03fffec57617e4c3396046960f49c463f5df.tar.bz2 |
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-x | Lib/test/test_array.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py index 33fb244..5190c35 100755 --- a/Lib/test/test_array.py +++ b/Lib/test/test_array.py @@ -398,6 +398,11 @@ class BaseTest(unittest.TestCase): if a.itemsize>1: self.assertRaises(ValueError, b.frombytes, b"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})) @@ -1113,6 +1118,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] |