Faker
One of the challenges in software development is it is preparing test data. Difficult to test well application if the database is empty. And if there are 2-3 records in the database, that too not all scenarios to check up.
It is not always possible to test on real databases, because there are questions about the processing of personal information and other secrets. That's why records in the database have to be generated automatically.
The Faker library just solves the problem of generating pseudo-random test data that looks believable. To not have to generate records like test1, test2, test3, ..., test100.
The Faker library generates:
- names of people;
- addresses;
- emails;
- phone numbers;
- bank accounts and credit card numbers;
- names of organizations and legal entities;
- dates and times;
- IP addresses and domain names;
- geographical coordinates;
and many others. See full list of so-called providers.
Faker library official documentation: faker.readthedocs.io.
Library installation:
pip install faker
An example of importing a library and generating a dozen random names and surnames of people:
from faker import Faker
fake = Faker()
for _ in range(10):
fake.name()
Result:
Jaime Flores
Michelle Clark
David Grant
Tyler Willis
Chelsea Bailey
Richard Thomas
Gary Morris
Jonathan Klein MD
Terry Sanders
Tina Miller