pytest-django
A Django plugin for pytest.
Decision gist · record as of 2026-08-14
Yes. pytest-django is actively maintained (release 4 days old), has no known vulnerabilities, low install friction, and is widely used (top 1000 PyPI packages by downloads). It's the standard way to run Django tests with pytest and is worth installing if your team prefers pytest's conventions and plugin ecosystem over Django's built-in test runner.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Django 5.2, 6.0, or latest main branch; Python 3.10+; pytest 7.0+.
- Django settings module must be configured via DJANGO_SETTINGS_MODULE environment variable or pytest.ini.
- Low friction: pure Python wheel, single runtime dependency (pytest), and actively maintained with a release 4 days old.
License · maintenance · safety
permissive license (permissive) — BSD 3-clause license (permissive): you can use, modify, and distribute pytest-django freely in commercial and private projects with minimal restrictions, provided you retain copyright notices.
last release 2026-08-10 (4 days) · last repo commit 2026-08-10 · 1,543 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 21,555,994 downloads/mo, #999 on PyPI
Alternatives
Verify before relying
pip install pytest-django
# In conftest.py or pytest.ini, configure Django settings
# pytest.ini: [pytest]
# DJANGO_SETTINGS_MODULE = myproject.settings
# Then write tests as regular functions:
# def test_user_creation(db):
# User.objects.create(username='test')
# assert User.objects.count() == 1- Whether database re-use across test runs (mentioned in description) applies to all database backends or only specific ones.
- Performance improvement magnitude when using pytest-xdist for parallel test execution with Django.
- Compatibility details with Django's async test features (if any).
What it is and what it does
pytest-django is a pytest plugin that bridges Django's test infrastructure with pytest's testing framework. Instead of using Django's manage.py test command, you write tests as regular functions and leverage pytest's fixture system, plugin ecosystem, and conventions. The plugin handles Django-specific setup like database transactions, test database creation, and settings configuration automatically.
It's designed for teams that prefer pytest's lighter syntax and richer plugin landscape over Django's unittest-based approach. The package maintains compatibility with Django 5.2, 6.0, and the latest development branch, supports both CPython 3.10+ and PyPy 3, and works alongside existing unittest-style TestCase classes without requiring changes to them.
Use it for
- Write Django unit tests as simple functions with pytest fixtures instead of TestCase subclasses.
- Reuse test database across multiple test runs to reduce setup overhead.
- Integrate pytest plugins (like pytest-xdist for parallel execution) into your Django test suite.
- Migrate an existing Django project from manage.py test to pytest incrementally.
- Use pytest's parametrize and fixture dependency injection for cleaner, more maintainable Django tests.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
pytest-django is actively maintained (release 4 days old), has no known vulnerabilities, low install friction, and is widely used (top 1000 PyPI packages by downloads). It's the standard way to run Django tests with pytest and is worth installing if your team prefers pytest's conventions and plugin ecosystem over Django's built-in test runner.
Install
pytest-django on PyPI
Before you install
Low friction: pure Python wheel, single runtime dependency (pytest), and actively maintained with a release 4 days old. Repository shows 1543 stars and recent commits.
Requires Django 5.2, 6.0, or latest main branch; Python 3.10+; pytest 7.0+. Django settings module must be configured via DJANGO_SETTINGS_MODULE environment variable or pytest.ini.
License in practice
BSD 3-clause license (permissive): you can use, modify, and distribute pytest-django freely in commercial and private projects with minimal restrictions, provided you retain copyright notices.
Quickstart
pip install pytest-django
# In conftest.py or pytest.ini, configure Django settings
# pytest.ini: [pytest]
# DJANGO_SETTINGS_MODULE = myproject.settings
# Then write tests as regular functions:
# def test_user_creation(db):
# User.objects.create(username='test')
# assert User.objects.count() == 1
Verify before relying
- Whether database re-use across test runs (mentioned in description) applies to all database backends or only specific ones.
- Performance improvement magnitude when using pytest-xdist for parallel test execution with Django.
- Compatibility details with Django's async test features (if any).
Package facts
| License | permissive license permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagepytest |
| Maintenance | Actively maintained 4 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 21,555,994 / month, #999 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableFramework :: DjangoFramework :: Django :: 5.2Framework :: Django :: 6.0Intended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Testing |
Evidence: pytest_django-4.14.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “django testing with pytest”
- pytest-djangopytest-django integrates Django with pytest, letting you write and…
- django-test-plusProvides a TestCase subclass for Django with helper methods to reduce…
- django-test-migrationsTests Django schema and data migrations, including forward/backward…
Give your agent the search over MCP, or paste the wish link into any chat.
More Testing packages
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.
Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.
Install it if you want to measure test completeness or enforce coverage thresholds in your project.
pytest-asyncio is a pytest plugin that enables writing and running async test functions using the asyncio library, allowing developers to await code directly within test cases.
Install it if you write tests for any asyncio-based code.
A pytest plugin that generates test reports in Common Test Report Format (CTRF) as JSON, compatible with pytest-xdist and pytest-playwright for distributed and browser-based testing.
Install it if you need CTRF-formatted test output for CI/CD integration or cross-tool reporting.
See also pytest-runner · django-webtest · pytest-selenium · django-test-plus · pytest-xprocess · pytest-base-url · pytest-faker · pytango · django-coverage-plugin