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

Method test_parsing

Lib/test/test_strtod.py:220–254  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

218
219 @unittest.skip("TODO: RUSTPYTHON; flaky test")
220 def test_parsing(self):
221 # make '0' more likely to be chosen than other digits
222 digits = '000000123456789'
223 signs = ('+', '-', '')
224
225 # put together random short valid strings
226 # \d*[.\d*]?e
227 for i in range(1000):
228 for j in range(TEST_SIZE):
229 s = random.choice(signs)
230 intpart_len = random.randrange(5)
231 s += ''.join(random.choice(digits) for _ in range(intpart_len))
232 if random.choice([True, False]):
233 s += '.'
234 fracpart_len = random.randrange(5)
235 s += ''.join(random.choice(digits)
236 for _ in range(fracpart_len))
237 else:
238 fracpart_len = 0
239 if random.choice([True, False]):
240 s += random.choice(['e', 'E'])
241 s += random.choice(signs)
242 exponent_len = random.randrange(1, 4)
243 s += ''.join(random.choice(digits)
244 for _ in range(exponent_len))
245
246 if intpart_len + fracpart_len:
247 self.check_strtod(s)
248 else:
249 try:
250 float(s)
251 except ValueError:
252 pass
253 else:
254 assert False, "expected ValueError"
255
256 @test.support.bigmemtest(size=test.support._2G+10, memuse=3, dry_run=False)
257 def test_oversized_digit_strings(self, maxsize):

Callers

nothing calls this directly

Calls 4

check_strtodMethod · 0.95
choiceMethod · 0.80
randrangeMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected