Factory_boy
uses fake-factory (Faker)
to generate random values, I would like to generate some random values in my Django tests using Faker directly.
Factory_boy docs suggests using factory.Faker
and its provider as :
class RandomUserFactory(factory.Factory):
class Meta:
model = models.User
first_name = factory.Faker('first_name')
But this isn't generating any name:
>>> import factory
>>> factory.Faker('name')
<factory.faker.Faker object at 0x7f1807bf5278>
>>> type(factory.Faker('name'))
<class 'factory.faker.Faker'>
From factory_boy
faker.py
class factory.Faker('ean', length=10)
calls faker.Faker.ean(length=10)
but Faker
docs says it should show a name:
from faker import Faker
fake = Faker()
fake.name()
# 'Lucy Cechtelar'
Is there any other way to use Faker
instead of setting an instance directly from Faker
?
from faker import Factory
fake = Factory.create()
fake.name()