Skip to main content

A pytest plugin for preserving the order in which Django runs tests.

Project description

pytest-django advertises “easy switching.” While it’s true that existing unittest-style tests will work without any modifications, you may have problems switching if you depend on the order in which the Django test runner runs tests. This plugin helps preserve that order if you need it to run your tests.

Motivation

The Django test runner gives priority to Django TestCase subclasses, executing them before other Django-based tests (e.g., TransactionTestCase) and any other unittest.TestCase tests. Put differently, Django runs tests which reset the database by rolling back a transaction before tests which reset the database by truncating all tables.

pytest-django doesn’t preserve this ordering out of the box. For more, see #214. This isn’t a problem if your project’s tests can run independently of each other, in any order. However, if your project’s tests rely on initial data populated via fixtures or migrations, tests which reset the database by rolling back a transaction must run before tests which reset the database by truncating all tables, thereby deleting any initial data. The serialized_rollback option can be used to deal with this issue within a TransactionTestCase, but it has no effect across distinct test cases; once you exit a TransactionTestCase, any initial data is gone.

Installation

This plugin supports Python 2.7, 3.5, and 3.6. Install with pip:

$ pip install pytest-django-ordering

You’re done! pytest will automatically find and integrate the plugin.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-django-ordering-1.1.0.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

pytest_django_ordering-1.1.0-py2.py3-none-any.whl (4.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pytest-django-ordering-1.1.0.tar.gz.

File metadata

  • Download URL: pytest-django-ordering-1.1.0.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.1 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/2.7.14

File hashes

Hashes for pytest-django-ordering-1.1.0.tar.gz
Algorithm Hash digest
SHA256 931763c469efd57c33c47da9b48d7d375d7675d93f96e471c7bb43da568f092a
MD5 66671b40a423fde80b348343f968e9f7
BLAKE2b-256 12326d153e02bd7e0292862cffa38fd58e6262bacbb1d7e5450c6f325bc988b7

See more details on using hashes here.

File details

Details for the file pytest_django_ordering-1.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: pytest_django_ordering-1.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.1 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/2.7.14

File hashes

Hashes for pytest_django_ordering-1.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 510319728a9ba6afb5cad3ab332ea6c9180fcdf10e088d6d14f70de679c707e6
MD5 cf360456d52d1e86c73d452f7801c4ee
BLAKE2b-256 ae5892638e04fefa897f2f709821adfc86e14013518d7ec0dc5f4d7f754a4ffa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page