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

Method test_pylong_roundtrip

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

Source from the content-addressed store, hash-verified

850 int(big_value)
851
852 def test_pylong_roundtrip(self):
853 from random import randrange, getrandbits
854 bits = 5000
855 while bits <= 1_000_000:
856 bits += randrange(-100, 101) # break bitlength patterns
857 hibit = 1 << (bits - 1)
858 n = hibit | getrandbits(bits - 1)
859 assert n.bit_length() == bits
860 sn = str(n)
861 self.assertNotStartsWith(sn, '0')
862 self.assertEqual(n, int(sn))
863 bits <<= 1
864
865 @support.requires_resource('cpu')
866 @unittest.skipUnless(_decimal, "C _decimal module required")

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected