MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_init_alloc

Method test_init_alloc

Lib/test/test_bytes.py:1615–1630  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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):

Callers

nothing calls this directly

Calls 7

listClass · 0.85
lenFunction · 0.85
__alloc__Method · 0.80
assertGreaterEqualMethod · 0.80
gFunction · 0.70
__init__Method · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected