Welcome to Python for Testers.
In this lesson you’ll learn:
- Why Python is useful for QA and automation
- How to write simple scripts for test data
- Example: generating test users
Why Python?
- Easy to learn, human-readable
- Huge library support (requests, pytest, pandas)
- Great for writing utilities to support testing
Example: Generate Fake Users
“`python
import csv
rows = [{“id”: i, “email”: f”user{i}@example.com”} for i in range(1, 6)]
with open(“fake_users.csv”, “w”, newline=””) as f:
writer = csv.DictWriter(f, fieldnames=[“id”, “email”])
writer.writeheader()
writer.writerows(rows)
print(“fake_users.csv generated”)