Faker package |generate fake data |boon for tester

What is Faker?
Faker is a python package that generates fake data for you. Now think about your project where you want lots of data to test, then what you will do…yeah you will just search some CSV or excel file from the net and download your data but it may not fulfil all your requirement then what to do…


Faker package is for you…it will
1.Bootstrap your database.
2.Create good-looking XML documents,
3.Use this data to stress test your Project.
4.Anonymize data taken from a production service.

You will say….”What the FAKE is this…its faking awesome package.

How to install?
You can use this command as per your convenience…

pip install faker
pip install fake-factory


But if you fail to install using these command just install this library via conda…
Use any one of these commands…
conda install -c conda-forge faker
conda install -c conda-forge/label/gcc7 faker
conda install -c conda-forge/label/cf201901 faker
conda install -c conda-forge/label/cf202003 faker

Once you are equipped with this package then you are free to generate fake data…but remember…

“Live True in this fake World”

Now you are able to generate lots of fake data and faker package gives you the ability to print or get lots of fake data and you can generate the frequently used data like…
• Name
• Address
• Email
• Country
• Date of birth
and so on.
So you can use these commands for the above data generation…

• fake.name()
• fake.address()
• fake.email()
• fake.country()
• fake.date()

Try this code :
Code :
from faker import Faker
fake = Faker()
print(“Name :”,fake.name())
print(“Address :”,fake.address())
print(“Email :”,fake.email())
print(“Country :”,fake.country())
print(“Date :”,fake.date())

Output :
Name : Emily Jefferson
Address : 35828 Chelsea Rapids Apt. 890
Andrewport, HI 58892
Email : jeffrey68@yahoo.com
Country : Madagascar
Date : 2017-09-14

But these names are english name but if you want to display name as per your country e.g if we want to display indian name, then we need to do some small changes….

Modified code for indian names :
Code :
from faker import Faker
fake = Faker([‘hi_IN’]) #Here is the change…
print(“Name :”,fake.name())
print(“Address :”,fake.address())
print(“Email :”,fake.email())
print(“Country :”,fake.country())
print(“Date :”,fake.date())

Output :

Name : शान्ता बालासुब्रमणियम
Address : 1 लाल
Email : udossii@mhaaraaj.com
Country : लिथुआनिया
Date : 2010-09-21


so use this package to test your code and generate tons of data without downloading it from the internet or depend on the data provider for the testing…