Skip to content

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

Open

Description

@lavr

Several unit tests download fixtures from the internet, so CI depends on external sites being available.

On 2026-09-28 the unit jobs failed on all Python versions because the gh-pages branch (which serves http://lavr.github.io/python-emails/tests/... via GitHub Pages) had been deleted on 2026-04-02. The branch was restored and CI is green again, but the dependency remains.

Affected tests

Fixtures from http://lavr.github.io/python-emails/tests/ (the tests/ directory of the gh-pages branch, ~800 KB):

  • emails/testsuite/loader/test_loaders.py: test_loaders, test_loaders_with_params, test_loader_image_callback (campaignmonitor-samples/...)
  • emails/testsuite/message/test_send.py: test_send_letters (python-logo.gif)
  • emails/testsuite/store/test_store.py: test_lazy_http (campaignmonitor-samples/sample-template/...)
  • emails/testsuite/test_utils.py: test_url_fix (url-fix/Пушкин А.С.jpg)

Other external hosts:

  • emails/testsuite/test_utils.py: test_fetch_url fetches http://google.com.

Proposal

  • Move the needed fixtures from gh-pages:tests/ into emails/testsuite/ (some, e.g. oldornament, already exist in emails/testsuite/loader/data).
  • Serve them from a local HTTP server fixture (see emails/testsuite/test_url_safety.py for an example of a threaded http.server fixture) and use its base url instead of lavr.github.io.
  • Since 1.1.3 the default emails.utils.url_validator rejects loopback addresses, so these tests need a fixture that sets emails.utils.url_validator = None (via monkeypatch).
  • Optionally keep a small number of real-network tests behind a marker (e.g. network) excluded from the default unit run.

Expected outcome

pytest -m "not e2e and not django" passes without network access.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions