(self)
| 1658 | (1 << (2 * bitlen)) - (1 << (bitlen + 1)) + 1) |
| 1659 | |
| 1660 | def test___sizeof__(self): |
| 1661 | self.assertEqual(int.__itemsize__, sys.int_info.sizeof_digit) |
| 1662 | |
| 1663 | # Pairs (test_value, number of allocated digits) |
| 1664 | test_values = [ |
| 1665 | # We always allocate space for at least one digit, even for |
| 1666 | # a value of zero; sys.getsizeof should reflect that. |
| 1667 | (0, 1), |
| 1668 | (1, 1), |
| 1669 | (-1, 1), |
| 1670 | (BASE-1, 1), |
| 1671 | (1-BASE, 1), |
| 1672 | (BASE, 2), |
| 1673 | (-BASE, 2), |
| 1674 | (BASE*BASE - 1, 2), |
| 1675 | (BASE*BASE, 3), |
| 1676 | ] |
| 1677 | |
| 1678 | for value, ndigits in test_values: |
| 1679 | with self.subTest(value): |
| 1680 | self.assertEqual( |
| 1681 | value.__sizeof__(), |
| 1682 | int.__basicsize__ + int.__itemsize__ * ndigits |
| 1683 | ) |
| 1684 | |
| 1685 | # Same test for a subclass of int. |
| 1686 | class MyInt(int): |
| 1687 | pass |
| 1688 | |
| 1689 | self.assertEqual(MyInt.__itemsize__, sys.int_info.sizeof_digit) |
| 1690 | |
| 1691 | for value, ndigits in test_values: |
| 1692 | with self.subTest(value): |
| 1693 | self.assertEqual( |
| 1694 | MyInt(value).__sizeof__(), |
| 1695 | MyInt.__basicsize__ + MyInt.__itemsize__ * ndigits |
| 1696 | ) |
| 1697 | |
| 1698 | # GH-117195 -- This shouldn't crash |
| 1699 | object.__sizeof__(1) |
| 1700 | |
| 1701 | def test_hash(self): |
| 1702 | # gh-136599 |
nothing calls this directly
no test coverage detected