🥸fake
A basic instance of Faker to generate test data.
What is Faker?
Put simply, Faker is a library that generates fake data for you.
Check out their docs when you have some time: https://faker.readthedocs.io
Three Ways to Use it
py.fake
- A basic Faker instance for UI testsfake fixture
- A fixture of Faker for any testsCreate your own
- Some users may need advanced functionality like Locales and Providers
This doc will go over the first two. Check out their docs for more advanced usage.
Syntax
Usage
What can I fake?
To see a full list of all the default providers that come out of the box, go to the link below:
FAQs
When I type py.fake.
, I'm not seeing address()
or anything else in your examples. What gives?
Because of the way Faker works with their Providers, you don't get IntelliSense. This is good and bad. Bad because you don't see all the options that are available, but good because you can create your own, custom Providers to generate almost everything you'd need for your applications and systems. Just type
py.fake.address()
and it will work!
Which of the three approaches should I use?
It's entirely up to you and your needs and style. This is completely valid:
If you need more advanced power, you can always create your own instance of Faker:
Last updated