Description
.. image:: https://img.shields.io/pypi/v/pytest-django.svg?style=flat :alt: PyPI Version :target: https://pypi.python.org/pypi/pytest-django .. image:: https://img.shields.io/pypi/pyversions/pytest-django.svg :alt: Supported Python versions :target: https://pypi.python.org/pypi/pytest-django .. image:: https://github.com/pytest-dev/pytest-django/workflows/main/badge.svg :alt: Build Status :target: https://github.com/pytest-dev/pytest-django/actions .. image:: https://img.shields.io/pypi/djversions/pytest-django.svg :alt: Supported Django versions :target: https://pypi.org/project/pytest-django/ .. image:: https://img.shields.io/codecov/c/github/pytest-dev/pytest-django.svg?style=flat :alt: Coverage :target: https://codecov.io/gh/pytest-dev/pytest-django Welcome to pytest-django! ========================= pytest-django allows you to test your Django project/applications with the `pytest testing tool <https://pytest.org/>`_. * `Quick start / tutorial <https://pytest-django.readthedocs.io/en/latest/tutorial.html>`_ * `Changelog <https://pytest-django.readthedocs.io/en/latest/changelog.html>`_ * Full documentation: https://pytest-django.readthedocs.io/en/latest/ * `Contribution docs <https://pytest-django.readthedocs.io/en/latest/contributing.html>`_ * Version compatibility: * Django: 4.2, 5.1, 5.2, 6.0 and latest main branch (compatible at the time of each release) * Python: CPython>=3.10 or PyPy 3 * pytest: >=7.0 For compatibility with older versions, use previous pytest-django releases. * Licence: BSD * `All contributors <https://github.com/pytest-dev/pytest-django/contributors>`_ * GitHub repository: https://github.com/pytest-dev/pytest-django * `Issue tracker <https://github.com/pytest-dev/pytest-django/issues>`_ * `Python Package Index (PyPI) <https://pypi.python.org/pypi/pytest-django/>`_ Install pytest-django --------------------- :: pip install pytest-django Why would I use this instead of Django's `manage.py test` command? ------------------------------------------------------------------ Running your test suite with pytest-django allows you to tap into the features that are already present in pytest. Here are some advantages: * `Manage test dependencies with pytest fixtures. <https://pytest.org/en/latest/how-to/fixtures.html>`_ * Less boilerplate tests: no need to import unittest, create a subclass with methods. Write tests 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 <https://pytest.org/en/latest/how-to/plugins.html>`_. * Works with both worlds: Existing unittest-style TestCase's still work without any modifications. See the `pytest documentation <https://pytest.org/en/latest/>`_ for more information on pytest itself.
Release History
| Version | Changes | Urgency | Date |
|---|---|---|---|
| 4.12.0 | Imported from PyPI (4.12.0) | Low | 4/21/2026 |
| v4.11.1 | https://github.com/pytest-dev/pytest-django/blob/main/docs/changelog.rst#v4111-2025-04-03 | Low | 4/3/2025 |
| v4.11.0 | https://github.com/pytest-dev/pytest-django/blob/main/docs/changelog.rst#v4110-2025-04-01 | Low | 4/1/2025 |
| v4.10.0 | https://github.com/pytest-dev/pytest-django/blob/main/docs/changelog.rst#v4100-2025-02-10 | Low | 2/10/2025 |
| v4.9.0 | https://github.com/pytest-dev/pytest-django/blob/main/docs/changelog.rst#v490-2024-09-02 | Low | 9/2/2024 |
| v4.8.0 | https://pytest-django.readthedocs.io/en/latest/changelog.html#v4-8-0-2024-01-30 | Low | 1/30/2024 |
| v4.7.0 | https://pytest-django.readthedocs.io/en/latest/changelog.html#v4-7-0-2023-11-08 | Low | 11/8/2023 |
| v4.6.0 | https://pytest-django.readthedocs.io/en/latest/changelog.html#v4-6-0-2023-10-30 | Low | 10/30/2023 |
| v4.5.2 | https://pytest-django.readthedocs.io/en/latest/changelog.html#v4-5-2-2021-12-07 | Low | 12/7/2021 |
| v4.5.1 | https://pytest-django.readthedocs.io/en/latest/changelog.html#v4-5-1-2021-12-02 | Low | 12/2/2021 |
| v4.5.0 | https://pytest-django.readthedocs.io/en/latest/changelog.html#v4-5-0-2021-12-01 | Low | 12/1/2021 |
| v4.3.0 | https://pytest-django.readthedocs.io/en/latest/changelog.html#v4-3-0-2021-05-15 | Low | 5/19/2021 |
| v4.1.0 | https://pytest-django.readthedocs.io/en/latest/changelog.html#v4-1-0-2020-10-22 | Low | 10/22/2020 |
| v4.0.0 | https://pytest-django.readthedocs.io/en/latest/changelog.html#v4-0-0-2020-10-16 | Low | 10/16/2020 |
| v3.8.0 | https://pytest-django.readthedocs.io/en/latest/changelog.html#v3-8-0-2020-01-14 | Low | 2/6/2020 |
| v3.5.1 | Release v3.5.1 | Low | 6/29/2019 |
| v3.5.0 | Features ^^^^^^^^ * Run tests in the same order as Django (#223) * Use verbosity=0 with disabled migrations (#729, #730) Bugfixes ^^^^^^^^ * django_db_setup: warn instead of crash with teardown errors (#726) Misc ^^^^ * 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) | Low | 6/3/2019 |
| 3.4.5 | Release 3.4.5 | Low | 1/7/2019 |
| 3.4.4 | 3.4.4 (2018-11-13) ------------------ Bugfixes ^^^^^^^^ * Refine the django.conf module check to see if the settings really are configured (#668). * Avoid crash after OSError during Django path detection (#664). Features ^^^^^^^^ * Add parameter info to fixture assert_num_queries to display additional message on failure (#663). Docs ^^^^ * Improve doc for django_assert_num_queries/django_assert_max_num_queries. * Add warning about sqlite specific snippet + fix typos (# | Low | 11/13/2018 |
| 3.4.3 | Release 3.4.3 | Low | 9/16/2018 |
| 3.4.2 | 3.4.2 (2018-08-20) ------------------ Bugfixes ^^^^^^^^ * Changed dependency for pathlib to pathlib2 (#636). * Fixed code for inserting the project to sys.path with pathlib to use an absolute path, regression in 3.4.0 (#637, #638). | Low | 8/20/2018 |
| 3.4.1 | Release 3.4.1 | Low | 8/16/2018 |
| 3.4.0 | 3.4.0 (2018-08-16) ------------------ Features ^^^^^^^^ * Added new fixture :fixture:`django_assert_max_num_queries` (#547). * Added support for ``connection`` and returning the wrapped context manager with :fixture:`django_assert_num_queries` (#547). * Added support for resetting sequences via :fixture:`django_db_reset_sequences` (#619). Bugfixes ^^^^^^^^ * Made sure to not call django.setup() multiple times (#629, #531). Compatibility ^^^^^^^^^^^^^ * Removed py de | Low | 8/16/2018 |
| 3.3.2 | Release 3.3.2 | Low | 6/21/2018 |
| 3.3.1 | 3.3.1 (2018-06-21) ------------------ Bug fixes ^^^^^^^^^ * Fixed test for classmethod with Django TestCases again (#618, introduced in #598 (3.3.0)). Compatibility ^^^^^^^^^^^^^ * Support Django 2.1 (no changes necessary) (#614). | Low | 6/21/2018 |
| 3.3.0 | Features ^^^^^^^^ * Added new fixtures ``django_mail_dnsname`` and ``django_mail_patch_dns``, used by ``mailoutbox`` to monkeypatch the ``DNS_NAME`` used in :py:mod:`django.core.mail` to improve performance and reproducibility. Bug fixes ^^^^^^^^^ * Fixed test for classmethod with Django TestCases (#597, #598). * Fixed RemovedInPytest4Warning: MarkInfo objects are deprecated (#596, #603) * Fixed scope of overridden settings with live_server fixture: previously they were | Low | 6/15/2018 |
| 3.2.0 | 3.2.0 ----- Features ^^^^^^^^ * Added new fixture `django_assert_num_queries` for testing the number of database queries (#387). * `--fail-on-template-vars` has been improved and should now return full/absolute path (#470). * Support for setting the live server port (#500). * unittest: help with setUpClass not being a classmethod (#544). Bug fixes ^^^^^^^^^ * Fix --reuse-db and --create-db not working together (#411). * Numerous fixes in the documentation. These should n | Low | 4/14/2018 |
