diff --git a/autoclear_mailbox.patch b/autoclear_mailbox.patch new file mode 100644 index 0000000..7425327 --- /dev/null +++ b/autoclear_mailbox.patch @@ -0,0 +1,16 @@ +--- + pytest_django/plugin.py | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- 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") diff --git a/python-pytest-django.changes b/python-pytest-django.changes index d33df16..99e7edb 100644 --- a/python-pytest-django.changes +++ b/python-pytest-django.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue Feb 22 18:40:14 UTC 2022 - Matej Cepl + +- Add autoclear_mailbox.patch checking for the existence of the + mail.outbox before clearing it (gh#pytest-dev/pytest-django#993). + ------------------------------------------------------------------- Mon Dec 27 15:43:56 UTC 2021 - Ben Greiner diff --git a/python-pytest-django.spec b/python-pytest-django.spec index a503bfb..57d4a47 100644 --- a/python-pytest-django.spec +++ b/python-pytest-django.spec @@ -1,7 +1,7 @@ # # spec file for package python-pytest-django # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -26,6 +26,10 @@ Summary: A Django plugin for py.test License: BSD-3-Clause URL: https://github.com/pytest-dev/pytest-django Source: https://files.pythonhosted.org/packages/source/p/pytest-django/pytest-django-%{version}.tar.gz +# PATCH-FIX-UPSTREAM autoclear_mailbox.patch gh#pytest-dev/pytest-django#993 mcepl@suse.com +# Protect against non-existant mail.outbox folder +# https://stackoverflow.com/q/5424498/164233 +Patch0: autoclear_mailbox.patch BuildRequires: %{python_module Django} BuildRequires: %{python_module pytest > 5.4.0} BuildRequires: %{python_module pytest-xdist} @@ -56,7 +60,7 @@ that are already present in pytest: * Works with both worlds: Existing unittest-style TestCase's still work without any modifications. %prep -%setup -q -n pytest-django-%{version} +%autosetup -p1 -n pytest-django-%{version} %build %python_build