Mercurial > cpython-lru_cache-weakref
diff Lib/test/test_array.py @ 67537:2581a17b29af
Issue #5109: array.array constructor will now use fast code when
initial data is provided in an array object with correct type.
| author | Alexander Belopolsky <alexander.belopolsky@gmail.com> |
|---|---|
| date | Tue, 11 Jan 2011 21:44:00 +0000 |
| parents | d36e345a1a3c |
| children | 3c9232a684ae |
line wrap: on
line diff
--- a/Lib/test/test_array.py Tue Jan 11 21:20:20 2011 +0000 +++ b/Lib/test/test_array.py Tue Jan 11 21:44:00 2011 +0000 @@ -398,6 +398,11 @@ 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 @@ 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]
