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

Function randfill

Modules/_decimal/tests/formathelper.py:295–314  ·  view source on GitHub ↗
(fill)

Source from the content-addressed store, hash-verified

293# Generate random format strings with a unicode fill character
294# [[fill]align][sign][#][0][width][,][.precision][type]
295def randfill(fill):
296 active = sorted(random.sample(range(5), random.randrange(6)))
297 s = ''
298 s += str(fill)
299 s += random.choice('<>=^')
300 for elem in active:
301 if elem == 0: # sign
302 s += random.choice('+- ')
303 elif elem == 1: # width
304 s += str(random.randrange(1, 100))
305 elif elem == 2: # thousands separator
306 s += ','
307 elif elem == 3: # prec
308 s += '.'
309 s += str(random.randrange(100))
310 elif elem == 4:
311 if 2 in active: c = 'EeGgFf%'
312 else: c = 'EeGgFfn%'
313 s += random.choice(c)
314 return s
315
316# Generate random format strings with random locale setting
317# [[fill]align][sign][#][0][width][,][.precision][type]

Callers

nothing calls this directly

Calls 4

strFunction · 0.85
randrangeMethod · 0.80
choiceMethod · 0.80
sampleMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…