Skip to main content

pytest-djangoapp

https://github.com/idlesign/pytest-djangoapp

PyPI - Version License Coverage Docs

Description

Nice pytest plugin to help you with Django pluggable application testing.

This exposes some useful tools for Django applications developers to facilitate tests authoring, including:

  • Settings overriding
  • Template tags testing
  • User creation
  • Request object creation
  • Management command calls
  • Mailing
  • Migrations
  • Messages
  • Signals
  • DB queries audit
  • Live server & client UI testing
  • Registered urlpatterns listing
  • Admin interface testing
  • etc.

Suitable for testing apps for Django 1.8+.

How to use

Let's say you have classical tests placing (inside application directory):

package_dir
|__ myapp
|  |__ __init__.py
|  |__ tests
|  |  |__ __init__.py
|  |  |__ conftest.py  <- Configure djangoapp here.
|
|__ pyproject.toml

Add the following lines into conftest.py to configure djangoapp and start using it:

from pytest_djangoapp import configure_djangoapp_plugin

pytest_plugins = configure_djangoapp_plugin()

Fixtures usage examples can be found in the documentation and the source code.

Testing an entire project

Despite the fact that djangoapp is primarily aimed to reusable Django applications testing one can use it also to test a project (a set of apps). For that, pass a dotted settings module path into settings argument:

pytest_plugins = configure_djangoapp_plugin(
    settings='myproject.settings.settings_testing',
    migrate=False,  # If you do not want to apply migrations.
)

What about pytest-django

pytest-djangoapp does not depend on pytest-django.

There are design decisions in pytest-django that might make it uncomfortable to work with.

  1. It uses setuptools entrypoints feature for pytest plugin discovery. It's not a problem by itself, but all kinds of bootstrapping with side effects made by pytest-django just on startup, make the plugin a poor choice for cases of system-wide (i.e. not venv) installations.

  2. Philosophy that next to no unit test should require DB access may be quite annoying.

  3. Some fixtures (e.g. django_assert_num_queries) usability arouse questions.

Despite that pytest-django is nice, of course.

pytest-djangoapp fixtures allow the use of Django without marking all relevant tests as needing a database, as is required by pytest-django which provides the django_db mark and db fixtures.

If you have pytest-django already installed, it can be disabled for projects using pytest-djangoapp by adding the following lines into pytest.ini:

[pytest]
addopts = -p no:django

Documentation

http://pytest-djangoapp.readthedocs.io/

Metadata

Release files for pytest-djangoapp 1.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-djangoapp 1.9.0
File Size Uploaded Provenance Actions
pytest_djangoapp-1.9.0.tar.gz 18.6 kB Without provenance Details for pytest_djangoapp-1.9.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytest-djangoapp 1.9.0
File Interpreter ABI Platform Actions
pytest_djangoapp-1.9.0-py3-none-any.whl Python 3 none any Details for pytest_djangoapp-1.9.0-py3-none-any.whl

Total release size: 44.7 kB

Release files / pytest_djangoapp-1.9.0.tar.gz

Download URL pytest_djangoapp-1.9.0.tar.gz
Size 18.6 kB
Tags Source
SHA-256 checksum
How to use checksums
475e7c2e8f3779bb133d02cc2febac6845d7866da2d307c6f6c1f3d61c9f8c87
BLAKE2b-256 checksum
How to use checksums
7e69a080dfa8b2948495436a38d370a63bb03b9be188b8306d50c1ceb5ce7b8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / pytest_djangoapp-1.9.0-py3-none-any.whl

Download URL pytest_djangoapp-1.9.0-py3-none-any.whl
Size 26.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1c12b47d62829049728968423d281f5123e475f81727169c0ea287b016e569f9
BLAKE2b-256 checksum
How to use checksums
af52280b0ec804f2cdb047a672e11789909d233ec219dc43c81df4b63a2f4f5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for pytest-djangoapp 1.9.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.9.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page