Use Case
Pytest Fixtures Powered by MockHero
conftest.py
import os, requests, pytest
@pytest.fixture(scope="session")
def dataset():
return requests.post(
"https://api.mockhero.dev/api/v1/generate",
json={
"seed": 42,
"tables": [
{"name": "users", "count": 20, "fields": [
{"name": "id", "type": "uuid"},
{"name": "email", "type": "email"}
]},
{"name": "orders", "count": 80, "fields": [
{"name": "id", "type": "uuid"},
{"name": "user_id", "type": "ref", "ref": "users.id"},
{"name": "total", "type": "price"}
]}
]
},
headers={"x-api-key": os.environ["MOCKHERO_API_KEY"]}
).json()
def test_has_twenty_users(dataset):
assert len(dataset["users"]) == 20
Get Started
M
MockHero Team
Guides and tutorials for generating realistic test data with the MockHero API.
Start generating test data for free
1,000 rows/month on the free tier. No credit card required.
Get Your API Key