Mimesis is a powerful data generator for Python that can produce a wide range of fake data in multiple languages. This tool is useful for populating testing databases, creating fake API endpoints, generating custom structures in JSON and XML files, and anonymizing production data, among other things. With Mimesis, developers can obtain realistic, randomized data easily to facilitate development and testing.
This python module can be install with pip tool easy.
See this simple example:
from mimesis import Person, Address, Text, Datetime
from mimesis.enums import Gender
def test_mimesis(locale: str, sex: str):
person = Person(locale)
address = Address(locale)
text = Text(locale)
dt = Datetime()
gender = Gender.MALE if sex == "male" else Gender.FEMALE
data = {
"first_name": person.first_name(gender=gender),
"last_name": person.last_name(),
"full_name": person.full_name(gender=gender),
"email": person.email(),
"telephone": person.telephone(),
"occupation": person.occupation(),
"address": address.address().replace("\n", ", "),
"city": address.city(),
"postal_code": address.postal_code(),
"country": address.country(),
"birth_date": dt.date(start=1970, end=2005),
"bio": text.text(quantity=2),
}
return data
if __name__ == "__main__":
npc = test_mimesis("en", "female")
for k, v in npc.items():
print(f"{k}: {v}")The result is:
python_313 test_mimesis.py
first_name: Nisha
last_name: Rocha
full_name: Hertha Wynn
email: stakeholders2063@protonmail.com
telephone: +14172413972
occupation: Medical Physicist
address: 865 Cooper Highway
city: Elkhart
postal_code: 69168
country: France
birth_date: 2004-06-11
bio: It is also a garbage-collected runtime system. Do you come here often?