From 6a54bccfb64ba740c4114369b476e18b8150f19d60f1a3a5b3463e1d4ae46880 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Tue, 22 Feb 2022 21:28:13 +0000 Subject: [PATCH] Accepting request 956874 from home:mcepl:branches:devel:languages:python - Add autoclear_mailbox.patch checking for the existence of the mail.outbox before clearing it (gh#pytest-dev/pytest-django#993). OBS-URL: https://build.opensuse.org/request/show/956874 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:django/python-pytest-django?expand=0&rev=30 --- autoclear_mailbox.patch | 16 ++++++++++++++++ python-pytest-django.changes | 6 ++++++ python-pytest-django.spec | 8 ++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 autoclear_mailbox.patch 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