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

Function test_parsing

Modules/_decimal/tests/randfloat.py:122–149  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

120 yield s
121
122def test_parsing():
123 # make '0' more likely to be chosen than other digits
124 digits = '000000123456789'
125 signs = ('+', '-', '')
126
127 # put together random short valid strings
128 # \d*[.\d*]?e
129 for i in range(1000):
130 for j in range(TEST_SIZE):
131 s = random.choice(signs)
132 intpart_len = random.randrange(5)
133 s += ''.join(random.choice(digits) for _ in range(intpart_len))
134 if random.choice([True, False]):
135 s += '.'
136 fracpart_len = random.randrange(5)
137 s += ''.join(random.choice(digits)
138 for _ in range(fracpart_len))
139 else:
140 fracpart_len = 0
141 if random.choice([True, False]):
142 s += random.choice(['e', 'E'])
143 s += random.choice(signs)
144 exponent_len = random.randrange(1, 4)
145 s += ''.join(random.choice(digits)
146 for _ in range(exponent_len))
147
148 if intpart_len + fracpart_len:
149 yield s
150
151test_particular = [
152 # squares

Callers 1

randfloat.pyFile · 0.85

Calls 3

choiceMethod · 0.80
randrangeMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…