Skip to main workspace
E2E TESTING GUIDE · PYTHON PYTEST

Python Pytest email & OTP verification without flaky sleeps or expensive SaaS.

Give every Python Pytest test case an isolated disposable inbox via POST /v1/mailboxes, await message.ready deterministically over Fetch SSE, extract your OTP or magic link, and tear down cleanly.

3-Step Deterministic Workflow

1. Provision per test

Call POST /v1/mailboxes to receive a unique address and 256-bit Bearer access_token.

2. Stream SSE event

Subscribe to GET /v1/mailboxes/me/events with Authorization: Bearer until message.ready arrives.

3. Extract & clean up

Read GET /v1/mailboxes/me/messages/{id} for text/HTML and DELETE /v1/mailboxes/me in teardown.

Copy-Ready Python Pytest OTP Verification Template

Python
import json
import re
import requests

API = "https://api.inboxflick.com/v1"

def wait_for_otp(token: str, timeout: int = 30) -> str:
    headers = {"Authorization": f"Bearer {token}"}
    with requests.get(f"{API}/mailboxes/me/events", headers=headers, stream=True, timeout=timeout) as resp:
        resp.raise_for_status()
        event_name = ""
        for raw_line in resp.iter_lines(decode_unicode=True):
            if not raw_line:
                continue
            if raw_line.startswith("event:"):
                event_name = raw_line.split(":", 1)[1].strip()
            elif raw_line.startswith("data:") and event_name == "message.ready":
                payload = json.loads(raw_line.split(":", 1)[1].strip())
                msg = requests.get(
                    f"{API}/mailboxes/me/messages/{payload['message_id']}",
                    headers=headers,
                    timeout=10,
                ).json()
                match = re.search(r"\b(\d{6})\b", msg["data"]["text_body"])
                if match:
                    return match.group(1)
    raise TimeoutError("OTP email not received")

def test_signup_otp(app_client):
    created = requests.post(f"{API}/mailboxes", json={}, timeout=10).json()["data"]
    address = created["mailbox"]["address"]
    token = created["access_token"]
    try:
        app_client.post("/signup", json={"email": address})
        otp = wait_for_otp(token)
        verify = app_client.post("/verify", json={"email": address, "code": otp})
        assert verify.status_code == 200
    finally:
        requests.delete(
            f"{API}/mailboxes/me",
            headers={"Authorization": f"Bearer {token}"},
            timeout=10,
        )

Running Parallel CI Workers? Batch-Create 1–20 Inboxes with Pro

Guest IPs allow 1 active inbox at a time (5/day). Upgrade to Pro ($1.99/mo or $8.99 one-time lifetime) to provision 1–20 parallel worker mailboxes in a single API call on isolated clean domains.

POST https://api.inboxflick.com/v1/member/mailboxes/batch
Authorization: Bearer <PRO_MEMBER_JWT>
Content-Type: application/json

{ "count": 20, "is_permanent": false }

Scale parallel CI email tests for $8.99 one-time

Unlock unlimited daily creation, 1–20 batch provisioning, isolated Pro domains, and 10,000 permanent inboxes.

playwright cypress vitest API Pro

CI Email Testing FAQ

Does Python Pytest need any third-party InboxFlick npm or pip package?
No. Standard fetch() or Python requests works directly against /v1 with Bearer auth.
How do parallel CI shards avoid hitting the guest 1-inbox IP limit?
Call POST /v1/member/mailboxes/batch with a Pro Member JWT ($1.99/mo or $8.99 lifetime) to allocate up to 20 concurrent inboxes per call.
Are verification links and HTML emails supported?
Yes. Each message returns both text_body and sanitized html_body for regex OTP or magic-link extraction.