()
| 316 | # Generate random format strings with random locale setting |
| 317 | # [[fill]align][sign][#][0][width][,][.precision][type] |
| 318 | def rand_locale(): |
| 319 | try: |
| 320 | loc = random.choice(locale_list) |
| 321 | locale.setlocale(locale.LC_ALL, loc) |
| 322 | except locale.Error as err: |
| 323 | pass |
| 324 | active = sorted(random.sample(range(5), random.randrange(6))) |
| 325 | s = '' |
| 326 | have_align = 0 |
| 327 | for elem in active: |
| 328 | if elem == 0: # fill+align |
| 329 | s += chr(random.randrange(32, 128)) |
| 330 | s += random.choice('<>=^') |
| 331 | have_align = 1 |
| 332 | elif elem == 1: # sign |
| 333 | s += random.choice('+- ') |
| 334 | elif elem == 2 and not have_align: # zeropad |
| 335 | s += '0' |
| 336 | elif elem == 3: # width |
| 337 | s += str(random.randrange(1, 100)) |
| 338 | elif elem == 4: # prec |
| 339 | s += '.' |
| 340 | s += str(random.randrange(100)) |
| 341 | s += 'n' |
| 342 | return s |
searching dependent graphs…