Skip to content

tests: serve HTTP fixtures from a local server instead of lavr.github.io - #216

Open
lavr wants to merge 1 commit into
masterfrom
tests/hermetic-http-fixtures
Open

lavr wants to merge 1 commit into
masterfrom
tests/hermetic-http-fixtures

Conversation

@lavr

@lavr lavr commented Sep 28, 2026

Copy link
Copy Markdown
Owner

Closes #215

Changes

  • Copy the fixtures used by unit tests from the gh-pages branch into emails/testsuite/data/http/ (144 KB: python-logo.gif, url-fix/Пушкин А.С.jpg, sample-template/template-widgets.html + the 7 images it references). oldornament is served from the existing emails/testsuite/loader/data/html_import/... copy, which is byte-identical to the gh-pages one.
  • New http_fixtures fixture in conftest.py: session-scoped local HTTP server serving emails/testsuite; returns its base url and disables emails.utils.url_validator for the test (loopback is blocked by default since 1.1.3).
  • test_loaders, test_loaders_with_params, test_loader_image_callback, test_lazy_http, test_fetch_url, test_url_fix, test_send_letters use the local server.
  • test_external_urls (real HN / python.org) is marked network (registered in setup.cfg); CI still runs it.

Testing

  • With outbound connections blocked (socket patched to allow loopback only): pytest -m "not e2e and not django and not network" → 146 passed.
  • pytest -m "not e2e and not django" → 147 passed; mypy clean.

After this is merged, the gh-pages branch is no longer needed by the tests.

🤖 Generated with Claude Code

Unit tests downloaded fixtures from lavr.github.io (gh-pages branch) and
google.com, so CI broke when gh-pages was deleted. Copy the needed
fixtures into emails/testsuite/data/http and serve emails/testsuite from
a session-scoped local HTTP server via the new http_fixtures fixture
(which also disables url_validator to allow loopback).

test_external_urls still uses real sites and is marked `network`.

Closes #215

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make unit tests hermetic: serve HTTP fixtures locally instead of lavr.github.io

1 participant