| 293 | # Generate random format strings with a unicode fill character |
| 294 | # [[fill]align][sign][#][0][width][,][.precision][type] |
| 295 | def 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] |