Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FakerLibrary cannot be initialized with multiple locales #42

Open
jrfigura opened this issue Feb 18, 2020 · 0 comments
Open

FakerLibrary cannot be initialized with multiple locales #42

jrfigura opened this issue Feb 18, 2020 · 0 comments

Comments

@jrfigura
Copy link

Faker Library supports initialization with multiple locales:
from faker import Faker
fake = Faker(['it_IT', 'en_US', 'ja_JP'])
for _ in range(10):
print(fake.name())

Whenever I try to initialize library with multiple locales it fails with error:
Error in file '/app/robot/keywords/InventoryImportKeywords.robot': Initializing test library 'FakerLibrary' with arguments [ locale=['ja_JP', 'de_DE', 'en_US'] ] failed: AttributeError: 'list' object has no attribute 'replace'
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/FakerLibrary/keywords.py", line 42, in init
self.fake = faker.factory.Factory.create(locale, providers)
File "/usr/local/lib/python3.8/site-packages/faker/factory.py", line 35, in create
locale = locale.replace('-', '
') if locale else DEFAULT_LOCALE

In factory.py file we always treat locale variable as a string with single argument and line:
locale = locale.replace('-', '_') if locale else DEFAULT_LOCALE
causes this issue

Would be super nice to have initialization with multiple locales implemented

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant