Sync from SUSE:SLFO:Main python-pytest-django revision 28d43d4e8e9fc92d7863a9e122b8c57b

This commit is contained in:
Adrian Schröter 2024-05-03 22:21:42 +02:00
commit 1fa5370c13
6 changed files with 452 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

16
autoclear_mailbox.patch Normal file
View File

@ -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")

BIN
pytest-django-4.5.2.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,32 @@
From 458d48aee50171d3dec0ad6c9502bf7d795f9da1 Mon Sep 17 00:00:00 2001
From: Stanislav Levin <slev@altlinux.org>
Date: Mon, 28 Feb 2022 13:12:37 +0300
Subject: [PATCH] tests: Sync expected stream for Pytest's version
https://docs.pytest.org/en/7.0.x/changelog.html#breaking-changes:
> [pytest#8246](https://github.com/pytest-dev/pytest/issues/8246): --version now writes version information to stdout rather than stderr.
Fixes: https://github.com/pytest-dev/pytest-django/issues/995
Signed-off-by: Stanislav Levin <slev@altlinux.org>
---
tests/test_manage_py_scan.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/tests/test_manage_py_scan.py b/tests/test_manage_py_scan.py
index 39544589..490882b0 100644
--- a/tests/test_manage_py_scan.py
+++ b/tests/test_manage_py_scan.py
@@ -118,7 +118,12 @@ def test_django_project_found_invalid_settings_version(django_testdir, monkeypat
result = django_testdir.runpytest_subprocess("django_project_root", "--version", "--version")
assert result.ret == 0
- result.stderr.fnmatch_lines(["*This is pytest version*"])
+ if hasattr(pytest, "version_tuple") and pytest.version_tuple >= (7, 0):
+ version_out = result.stdout
+ else:
+ version_out = result.stderr
+
+ version_out.fnmatch_lines(["*This is pytest version*"])
result = django_testdir.runpytest_subprocess("django_project_root", "--help")
assert result.ret == 0

View File

@ -0,0 +1,294 @@
-------------------------------------------------------------------
Thu Dec 8 10:39:03 UTC 2022 - pgajdos@suse.com
- six is not required for build
-------------------------------------------------------------------
Mon Mar 28 21:54:21 UTC 2022 - Ben Greiner <code@bnavigator.de>
- Add pytest-django-pr996-pytest7.patch
* gh#pytest-dev/pytest-django#996
-------------------------------------------------------------------
Tue Feb 22 18:40:14 UTC 2022 - Matej Cepl <mcepl@suse.com>
- 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 <code@bnavigator.de>
- Update to 4.5.2
* Bugfixes
* Fix regression in v4.5.0 -
pytest.mark.django_db(reset_sequence=True) now implies
transaction=True again.
- Release v4.5.1
* Bugfixes
* Fix regression in v4.5.0 - database tests inside (non-unittest)
classes were not ordered correctly to run before non-database
tests, same for transactional tests before non-transactional
tests.
- Release v4.5.0
* Improvements
* Add support for :ref:`rollback emulation/serialized rollback
<test-case-serialized-rollback>`. The
:func:`pytest.mark.django_db` marker has a new
serialized_rollback option, and a
:fixture:`django_db_serialized_rollback` fixture is added.
* Official Python 3.10 support.
* Official Django 4.0 support (tested against 4.0rc1 at the time
of release).
* Drop official Django 3.0 support. Django 2.2 is still
supported, and 3.0 will likely keep working until 2.2 is
dropped, but it's not tested.
* Added pyproject.toml file.
* Skip Django's setUpTestData mechanism in pytest-django tests.
It is not used for those, and interferes with some planned
features. Note that this does not affect setUpTestData in
unittest tests (test classes which inherit from Django's
TestCase).
* Bugfixes
* Fix :fixture:`live_server` when using an in-memory SQLite
database.
* Fix typing of assertTemplateUsed and assertTemplateNotUsed.
- Release v4.4.0
* Improvements
* Add a fixture :fixture:`django_capture_on_commit_callbacks` to
capture :func:`transaction.on_commit()
<django.db.transaction.on_commit>` callbacks in tests.
- Release v4.3.0
* Improvements
* Add experimental :ref:`multiple databases <multi-db>` (multi
db) support.
* Add type annotations. If you previously excluded pytest_django
from your type-checker, you can remove the exclusion.
* Documentation improvements.
- Release v4.2.0
* Improvements
* Official Django 3.2 support.
* Documentation improvements.
* Bugfixes
* Disable atomic durability check on non-transactional tests
(#910).
- Skip python36: no python36-Django 4 in TW
-------------------------------------------------------------------
Wed Oct 28 23:58:45 UTC 2020 - John Vandenberg <jayvdb@gmail.com>
- Disable Python 2
- Drop no longer needed patches:
* ignore-warnings.patch
* pytest-django-pytest6.patch
- Update to v4.1.0
* Add the async_client and async_rf fixtures
* Add django_debug_mode to configure how DEBUG is set in tests
* Make admin_user work for custom user models without an email
field.
- from v4.0.0
* Drop support for Python versions before 3.5
* Drop support for Django versions before 2.2
* Drop support for pytest versions before 5.4
* Officialy support Python 3.9.
* Add pytest_django.__version__
* Make the admin_user and admin_client fixtures compatible with
custom user models which dont have a username field
* Change the admin_user fixture to use get_by_natural_key()
to get the user instead of directly using USERNAME_FIELD,
in case it is overridden, and to match Django
-------------------------------------------------------------------
Wed Sep 2 13:19:37 UTC 2020 - Benjamin Greiner <code@bnavigator.de>
- Fix test failure with pytest 6
* pytest-django-pytest6.patch
* The patched call signature looks weird, but it works as intended
* Patch is part of gh#pytest-dev/pytest-django#855
- Replace deprecated py.test call with %pytest macro
-------------------------------------------------------------------
Mon Aug 24 11:50:24 UTC 2020 - Marketa Calabkova <mcalabkova@suse.com>
- Fix build with ignore-warnings.patch
-------------------------------------------------------------------
Fri Apr 3 10:20:28 UTC 2020 - Tomáš Chvátal <tchvatal@suse.com>
- Update to 3.9.0:
* Improve test ordering with Django test classes (#830)
* Remove import of pkg_resources for parsing pytest version (performance) (#826)
* Work around unittest issue with pytest 5.4.{0,1} (#825)
* Don't break --failed-first when re-ordering tests (#819, #820)
* pytest_addoption: use group.addoption (#833)
-------------------------------------------------------------------
Fri Mar 13 12:43:21 UTC 2020 - Tomáš Chvátal <tchvatal@suse.com>
- Fix build without python2
-------------------------------------------------------------------
Thu Jan 23 08:49:57 UTC 2020 - Tomáš Chvátal <tchvatal@suse.com>
- Update 3.8.0:
* Make Django's assertion helpers available in pytest_django.asserts (#709).
* Report django-configurations setting (#791)
-------------------------------------------------------------------
Fri Nov 15 10:49:15 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com>
- Update to 3.7.0:
* Monkeypatch pytest to not use ``TestCase.debug`` with unittests, instead
of patching it into Django (#782).
* Work around pytest crashing due to ``pytest.fail`` being used from within the
DB blocker, and pytest trying to display an object representation involving
DB access (#781). pytest-django uses a ``RuntimeError`` now instead.
-------------------------------------------------------------------
Wed Oct 30 11:54:08 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com>
- Update to 3.6.0:
* Rename test databases when running parallel Tox (#678, #680)
* Django unittests: restore "debug" function (#769, #771)
-------------------------------------------------------------------
Thu Aug 22 13:40:41 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com>
- Simplify the deps
-------------------------------------------------------------------
Tue Jul 2 12:10:47 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com>
- Update to 3.5.1:
* Fix compatibility with pytest 5.x (#751)
-------------------------------------------------------------------
Mon Jun 17 12:07:05 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com>
- Update to 3.5.0:
* Run tests in the same order as Django (#223)
* Use verbosity=0 with disabled migrations (#729, #730)
* django_db_setup: warn instead of crash with teardown errors (#726)
* tests: fix test_sqlite_database_renamed (#739, #741)
* tests/conftest.py: move import of db_helpers (#737)
* Cleanup/improve coverage, mainly with tests (#706)
* Slightly revisit unittest handling (#740)
-------------------------------------------------------------------
Wed Feb 27 13:33:32 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com>
- Update to 3.4.8:
* Various test fixes only
-------------------------------------------------------------------
Sun Feb 24 01:48:37 UTC 2019 - John Vandenberg <jayvdb@gmail.com>
- Add docs/ and AUTHORS to %doc
- Update to v3.4.7
* Fix disabling/handling of unittest methods with pytest 4.2+
- from 3.4.6
* django_find_project: add cwd as fallback always
* Enable tests for Django 2.2 and add classifier
- from 3.4.5
* Use request.config instead of pytest.config
* fixture 'admin_user' handle "email" username_field
* Minor doc fixes
- Add 'six' as explicit build dependency
-------------------------------------------------------------------
Mon Dec 10 15:17:57 UTC 2018 - Tomáš Chvátal <tchvatal@suse.com>
- Version update to 3.4.4:
* Many many changes to list properly
- Drop obsolete patch python-pytest-django-dependency.patch
-------------------------------------------------------------------
Thu Oct 12 14:06:41 UTC 2017 - jengelh@inai.de
- Improve write style of description.
-------------------------------------------------------------------
Wed Aug 23 14:48:12 UTC 2017 - t.gruner@katodev.de
- Change spec-file for multi-python build
-------------------------------------------------------------------
Wed Feb 22 18:33:31 CET 2017 - sbrabec@suse.com
- Relax fixed dependency on an old version of python-setuptools_scm
(python-pytest-django-dependency.patch,
suggested by michal@cihar.com).
-------------------------------------------------------------------
Mon Dec 5 22:34:03 UTC 2016 - buschmann23@opensuse.org
- Update to 3.1.2
+ Bug fixes
* Auto clearing of mail.outbox has been re-introduced to not break
functionality in 3.x.x release. This means that Compatibility
issues mentioned in the 3.1.0 release are no longer present.
- Update to 3.1.1
+ Bug fixes
* Workaround pdb interaction with Django TestCase. The issue
is caused by Django TestCase not implementing TestCase.debug()
properly but was brought to attention with recent changes in
pytest 3.0.2.
- Update to 3.1.0
+ Features
* Added new function scoped fixture mailoutbox that gives access
to djangos mail.outbox. The will clean/empty the mail.outbox
to assure that no old mails are still in the outbox.
* If django.contrib.sites is in your INSTALLED_APPS, Site cache
will be cleared for each test to avoid hitting the cache and
cause wrong Site object to be returned by Site.objects.get_current().
+ Compatibility
* IMPORTANT: the internal autouse fixture _django_clear_outbox has
been removed. If you have relied on this to get an empty outbox
for your test, you should change tests to use the mailoutbox
fixture instead. See documentation of mailoutbox fixture for usage.
If you try to access mail.outbox directly, AssertionError will be raised.
- Update to 3.0.0
+ Bug fixes
* Fix error when Django happens to be imported before
pytest-django runs. Thanks to Will Harris for the bug report.
+ Features
* Added a new option --migrations to negate a default usage of
--nomigrations.
* The previously internal pytest-django fixture that handles
database creation and setup has been refactored, refined and
made a public API.
+ Compoatibility
* Official for the pytest 3.0.0 (2.9.2 release should work too,
though). The documentation is updated to mention pytest instead
of py.test.
* Django versions 1.4, 1.5 and 1.6 is no longer supported. The
supported versions are now 1.7 and forward. Django master is
supported as of 2016-08-21.
* pytest-django no longer supports Python 2.6.
* Specifying the DJANGO_TEST_LIVE_SERVER_ADDRESS environment
variable is no longer supported. Use DJANGO_LIVE_TEST_SERVER_ADDRESS
instead.
* Ensuring accidental database access is now stricter than before.
Previously database access was prevented on the cursor level. To
be safer and prevent more cases, it is now prevented at the
connection level. If you previously had tests which interacted
with the databases without a database cursor, you will need to
mark them with the pytest.mark.django_db() marker or request
the db fixture.
* The previously undocumented internal fixtures _django_db_setup,
_django_cursor_wrapper have been removed in favour of the new
public fixtures. If you previously relied on these internal
fixtures, you must update your code.
-------------------------------------------------------------------
Mon Nov 9 12:56:30 UTC 2015 - mcihar@suse.cz
- Install license
-------------------------------------------------------------------
Mon Nov 9 10:59:03 UTC 2015 - mcihar@suse.cz
- Initial packaging

84
python-pytest-django.spec Normal file
View File

@ -0,0 +1,84 @@
#
# spec file for package python-pytest-django
#
# 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
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%{?!python_module:%define python_module() python3-%{**}}
%define skip_python2 1
Name: python-pytest-django
Version: 4.5.2
Release: 0
Summary: A Django plugin for Pytest
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
# PATCH-FIX-UPSTREAM pytest-django-pr996-pytest7.patch -- gh#pytest-dev/pytest-django#996
Patch1: https://github.com/pytest-dev/pytest-django/pull/996.patch#/pytest-django-pr996-pytest7.patch
BuildRequires: %{python_module Django}
BuildRequires: %{python_module pytest > 5.4.0}
BuildRequires: %{python_module pytest-xdist}
BuildRequires: %{python_module setuptools_scm >= 5.0.0}
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
BuildRequires: sqlite3
Requires: python-Django
Requires: python-pytest > 5.4.0
BuildArch: noarch
%python_subpackages
%description
pytest-django allows testing Django projects/applications with the
pytest testing tool.
Running the test suite with pytest-django allows tapping into the features
that are already present in pytest:
* Manage test dependencies with pytest fixtures.
* Less boilerplate tests: no need to import unittest and creating a
subclass with methods. Tests can be written as regular functions.
* Database re-use: no need to re-create the test database for every test run.
* Run tests in multiple processes for increased speed (with the pytest-xdist plugin).
* Make use of other pytest plugins.
* Works with both worlds: Existing unittest-style TestCase's still work without any modifications.
%prep
%autosetup -p1 -n pytest-django-%{version}
%build
%python_build
%install
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
# memory operations fail in OBS server-side, thus skip them
export DJANGO_SETTINGS_MODULE=pytest_django_test.settings_sqlite
export PYTHONPATH=$(pwd)
%pytest -v tests/ -k 'not (test_sqlite_in_memory_used or test_django_assert_num_queries_db or test_django_assert_max_num_queries_db)'
%files %{python_files}
%license LICENSE
%doc AUTHORS README.rst docs/*.rst
%{python_sitelib}/pytest_django
%{python_sitelib}/pytest_django-%{version}*-info
%changelog