#100 AI security and governance 5.2 min
Fake but Realistic Test Data in Python With Faker
A quick comma-split loader failed on all 200 rows of realistic fake customers.
Predict a changed seed
Copy the code folder first. This needs Faker, as in the video, and I could not run it, so treat it as a prediction. In people.py change the default seed=7 in make() to seed=8, then run compare.py. In compare.py the other seed passed in is also 8. Predict what the first line says about the other seed differing, and why. Write your prediction down, then run it.
A hint
Look at what the first line compares: make(COUNT, seed=8) and make(COUNT).
Predict a smaller set
This needs Faker, as in the video, and I could not run it, so treat it as a prediction. In compare.py change COUNT from 200 to 20. Predict what the four email lines say about reserved domains, and what the quick loader line says. Write your predictions down, then run compare.py and see whether the pattern from the video still holds.
A hint
The safe calls should stay on reserved domains. Think about what the other two calls do.
Avoid commas in the address
This needs Faker, as in the video, and I could not run it, so treat it as a prediction. In people.py change .replace('\n', ', ') to .replace('\n', '; ') so the address has no comma from that line break. Predict how many rows the quick loader now gets wrong, then run compare.py. Compare with the 200 of 200 in the video.
A hint
Some other part of a fake address or name might still contain a comma.
Try another locale
This needs Faker, as in the video, and I could not run it, so treat it as a prediction. In people.py change Faker('en_GB') to Faker('de_DE'). Predict which printed lines will change and which will not, especially the reserved domain lines and the apostrophe or hyphen count. Write your prediction down, then run compare.py. The video tested only one locale.
A hint
Names and addresses change with the locale. Think about what the email calls look at.
These tasks are for you to try on your own machine. Nothing is checked or saved.
What this does not show
200 made-up customers from one library (Faker 40.41.0), one locale (en_GB) and one seed; only four email calls tested; the date of birth depends on the day you run it; fake rows are not the shape of your real data.
Up next in AI security and governance
More in AI security and governance
- #18 Prompt Injection Live: Attacking My Own LLM App
- #19 Redact Personal Data Before Your LLM Sees It (Python)
- #88 Indirect Prompt Injection: A Note That Gave Orders
- #89 Jailbreak-Test Your Own App: Eight Wrappers, Counted
- #90 Stop Leaking API Keys: Build a Secret Scanner in Python
- #91 Rate Limiting an LLM API: Token Bucket in FastAPI
Related videos
- #101 Differential Privacy Basics: Noisy Counts in Python AI security and governance
- #171 TDD With an AI Assistant: Red, Green, Refactor (unittest) AI coding and productivity
- #172 Refactor Safely With AI: Characterisation Tests (pytest) AI coding and productivity
- #208 Right to Erasure Across a Pipeline: Delete, Scan, Restore Data governance
