Share faker generator with Factory Boy's faker registry
See original GitHub issueThe problem
No documented way to share an existing faker generator with Factory Boy. Sometimes you might not always want to use the faker library from Factory Boy’s Faker class, so it would be nice if Factory Boy could share a common faker generator.
Proposed solution
Allow an easy way to attach an existing faker generator to Factory Boy. Perhaps something like factory.Faker.attach_fake(faker_generator)
, assuming that’s possible?
Workaround
import factory
from faker import Factory as FakerFactory
LOCALE = 'en-US'
fake = FakerFactory.create(locale=LOCALE)
factory.Faker._DEFAULT_LOCALE = LOCALE
factory.Faker._FAKER_REGISTRY[LOCALE] = fake
Extra notes
- Relates to #407
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Developers - Share faker generator with Factory Boy's faker registry -
No documented way to share an existing faker generator with Factory Boy. Sometimes you might not always want to use the faker library...
Read more >Locale en_US — Faker 15.3.4 documentation
Generate a random timezone (see faker.timezone for any args) and return as a python object usable as a tzinfo to datetime or other...
Read more >FakerPHP / Faker
Faker is a PHP library that generates fake data for you. ... Use Faker\Factory::create() to create and initialize a faker generator, which can...
Read more >How to use Faker from Factory_boy - python - Stack Overflow
You can use faker with factory_boy like this: class RandomUserFactory(factory.Factory): class Meta: model = models.User first_name = factory.
Read more >fake news generator app
( Example : app brand cool kids ) Most people use the fake name generator and fake email generator for successful registration on...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I believe resolving #407 resolves this issue as well. Since this one was created in hope to work around the former. As it is you can add custom providers:
And set the seed. Although I believe it’s poorly documented. And I’m going to file a corresponding issue. I can mention there anybody interested.
Setting the locale: https://github.com/FactoryBoy/factory_boy/issues/407#issuecomment-754281399 https://github.com/FactoryBoy/factory_boy/pull/832
Adding providers: see the previous post.
Setting the seed: https://github.com/FactoryBoy/factory_boy/issues/833