35. Data-Driven Testing with JSON, CSV & pytest Parameters

Data-Driven Testing in Python

import json
import time

def load_test_credentials(file_path: str):
with open(file_path, "r", encoding="utf-8") as f:
return json.load(f)

def generate_random_user():
return {
"username": f"user_{int(time.time())}@targetqa.com",
"role": "STANDARD"
}

Task

  • Implement make_user(prefix):
  • 1. Return {"email": f"{prefix}_{int(time.time())}@targetqa.com"}
πŸ’‘Common doubts
Did you like the problem?
Lesson 35 of 43
Python
Loading code editor…
Next