{
  "id": 11424933,
  "title": "FastAPI: emails de prueba con un buzón por ejecución",
  "url": "https://urgent.news/2026/10/02/fastapi-emails-de-prueba-con-un-buzon-por-ejecucion",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-02T11:23:25.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/oliviachen7/fastapi-emails-de-prueba-con-un-buzon-por-ejecucion-m9e"
  },
  "original_language": "es",
  "account": "FastAPI allows testing email verification by creating a unique inbox for each test execution. However, when multiple tests share the same inbox, issues can arise. Emails from previous executions may be found by tests, multiple users may receive messages, and retries can consume the same token as the first attempt. This can make reproducing failures difficult. To solve this, FastAPI offers a practical solution: each execution should have its own logical inbox, correlation identifier, and clear expiration date. The problem with sharing a test inbox is that \"last\" is not a stable property when parallelism is involved. Common issues include finding an email from a previous execution, multiple test users receiving messages, and reusing the same token from the first attempt. The CI saves the entire email body in an artifact, and cleaning depends on the test finishing without errors. Even a dummy email search can end up in support logs. Therefore, it's beneficial for the fixture to be readable by a person, but not depend on interpreting free text to know which execution it belongs to. Every execution must guarantee four pieces: unique identity, limited reading, finding messages after the start time with an exact recipient and known subject, and idempotent consumption. The buzons and messages must also be deletable even if the assertion fails. The inbox address doesn't need to be pretty; something like qa+run-8f31@example.test communicates more than a fixed address and makes it easier to relate a FastAPI request with the message it generated. A simple fixture for FastAPI is shown below. InboxClient represents the test inbox provider and can be a fake local during unit tests. First, it generates a unique run_id and uses it in the address or inbox identifier. It then reads emails with a time limit, consumes them idempotently, and deletes them after expiration. The inbox address doesn't need to be pretty, like qa+run-8f31@example.test. This communicates more than a fixed address and makes it easier to relate a FastAPI request with the generated message. The fixture ensures that each execution creates a unique inbox, the filter combines recipient, subject, and start time, prevents message consumption twice, eliminates the inbox even if an assertion fails, has a backup expiration cleanup, and doesn't include full tokens or unnecessary bodies in logs. The timeout provides actionable diagnostics. With this contract, email tests no longer depend on luck, allowing API retries, parallel test execution, and easier failure diagnosis. It's a small improvement that becomes noticeable as the project grows.",
  "summary": "Cuando una API envía un email de verificación, el test suele parecer sencillo: crear usuario, esperar el mensaje y abrir el enlace. El problema aparece cuando varios tests comparten el mismo buzón. Un mensaje viejo puede pasar por nuevo, un reintento puede leer el token de otra ejecución y el fallo termina siendo dificil de reproducir. En proyectos con FastAPI he encontrado una solución muy…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}