MarketSquare / MarketSquare/robotframework-faker
FakerLibrary cannot be initialized with multiple locales
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 69
- Forks
- 23
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in FakerLibrary/keywords.py at the initialization call on line 42 and reproduce the Robot Framework failure with a locale list. Compare that call with faker.factory.Factory.create and factory.py's locale handling. Done means FakerLibrary initializes with multiple locales and the demonstrated name-generation usage works without the AttributeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100