MCPcopy Index your code
hub / github.com/python/cpython / test_pylong_roundtrip

Method test_pylong_roundtrip

Lib/test/test_int.py:842–853  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

840 int(big_value)
841
842 def test_pylong_roundtrip(self):
843 from random import randrange, getrandbits
844 bits = 5000
845 while bits <= 1_000_000:
846 bits += randrange(-100, 101) # break bitlength patterns
847 hibit = 1 << (bits - 1)
848 n = hibit | getrandbits(bits - 1)
849 assert n.bit_length() == bits
850 sn = str(n)
851 self.assertNotStartsWith(sn, '0')
852 self.assertEqual(n, int(sn))
853 bits <<= 1
854
855 @support.requires_resource('cpu')
856 @unittest.skipUnless(_decimal, "C _decimal module required")

Callers

nothing calls this directly

Calls 4

strFunction · 0.85
bit_lengthMethod · 0.80
assertNotStartsWithMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected