(self)
| 1613 | # self.assertGreaterEqual since, in RustPython, the underlying storage |
| 1614 | # is a Vec which doesn't require trailing null byte. |
| 1615 | def test_init_alloc(self): |
| 1616 | b = bytearray() |
| 1617 | def g(): |
| 1618 | for i in range(1, 100): |
| 1619 | yield i |
| 1620 | a = list(b) |
| 1621 | self.assertEqual(a, list(range(1, len(a)+1))) |
| 1622 | self.assertEqual(len(b), len(a)) |
| 1623 | self.assertLessEqual(len(b), i) |
| 1624 | alloc = b.__alloc__() |
| 1625 | self.assertGreaterEqual(alloc, len(b)) # NOTE: RUSTPYTHON patched |
| 1626 | b.__init__(g()) |
| 1627 | self.assertEqual(list(b), list(range(1, 100))) |
| 1628 | self.assertEqual(len(b), 99) |
| 1629 | alloc = b.__alloc__() |
| 1630 | self.assertGreaterEqual(alloc, len(b)) # NOTE: RUSTPYTHON patched |
| 1631 | |
| 1632 | @unittest.expectedFailure # TODO: RUSTPYTHON |
| 1633 | def test_extend(self): |
nothing calls this directly
no test coverage detected