File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99import random
1010import shutil
1111
12+ from functools import lru_cache
1213from unidecode import unidecode
1314
1415from django .conf import settings
2425
2526fake = faker .Factory .create ()
2627
27- def random_faker ():
28+ @lru_cache (maxsize = 1 )
29+ def acceptable_fakers ():
2830 # The transliteration of some arabic and devanagari names introduces
2931 # non-alphabetic characgters that don't work with the draft author
3032 # extraction code, and also don't seem to match the way people with arabic
3133 # names romanize arabic names. Exlude those locales from name generation
3234 # in order to avoid test failures.
3335 locales = set ( [ l for l in faker .config .AVAILABLE_LOCALES if not (l .startswith ('ar_' ) or l .startswith ('sg_' )) ] )
34- return faker .Faker (random .sample (locales , 1 )[0 ])
36+ return [faker .Faker (locale ) for locale in locales ]
37+
38+ def random_faker ():
39+ return random .sample (acceptable_fakers (), 1 )[0 ]
3540
3641class UserFactory (factory .DjangoModelFactory ):
3742 class Meta :
You can’t perform that action at this time.
0 commit comments