From 1e8d1ccbfa95a2878c2e655e908f060f3435a19e Mon Sep 17 00:00:00 2001 From: symwell <111290954+symwell@users.noreply.github.com> Date: Fri, 7 Oct 2022 10:08:35 -0400 Subject: [PATCH] fix: don't crash if mail.outbox doesn't exist --- pytest_django/plugin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pytest_django/plugin.py b/pytest_django/plugin.py index e2b6f120..136c8edd 100644 --- a/pytest_django/plugin.py +++ b/pytest_django/plugin.py @@ -502,7 +502,8 @@ def _dj_autoclear_mailbox() -> None: from django.core import mail - del mail.outbox[:] + if hasattr(mail, "outbox"): + del mail.outbox[:] @pytest.fixture(scope="function")