Skip to main content

Tools for sorting test cases

Project description

python>=3.8

Project description

pytest-sort is a pytest plugin to automatically change the execution order of test cases. Changing the order of execution can help find test cases that only succeed because a different test left the system in a favorable state.

This plugin provides several options for controlling how the test cases are reordered.

Quick Start

Installation:

pip install pytest-sort -upgrade

Running with pytest-sort:

pytest --sort_mode=random

By default, all tests from the same module will run together. This command will run the tests within the module in a random order.

pytest --help

In the pytest-sort section, all currently avaialable options will be listed.

You may also set options in any pytest configruation file.

Options

Sort Bucket

Default: module

This option controls the scope of the sort operation. For example, if the sort bucket is "module", then all tests from the same module will run together. If the sort bucket is global, than all tests are sorted together.

Example:

pytest --sort_bucket=package
sort_bucket Definition
global Apply sort to all items together
package Group together test cases that are in the same package (folder)
module Group together test cases that are in the same module (py file)
class Group together test cases that are members of a class. All other test cases are grouped by module
parent Group together test cases by their immediate parent
grandparent Group together test cases by their parent's parent

Sort Mode

Default: none

This option controlls how the order is modified within the bucket.

Example:

pytest --sort_mode=md5
sort_mode Definition
none pytest_sort will not modify the sort order. This option disables pytest_sort.
md5 This mode creates an md5 of each test case id, then sorts on those values.
This runs test cases in a deterministicly shuffled order.
random Test cases are shuffled randomly
fastest In each run in "fasttest" mode, the plugin will track the longest execution time for each test case in a file '.pytest-sort'.
At the beginning of a test run, any previously recorded values will be used to sort the tests so that the fastest test runs first.
This is intended for use with "-x" or "--exitfirst"

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-sort-0.0.1.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

pytest_sort-0.0.1-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file pytest-sort-0.0.1.tar.gz.

File metadata

  • Download URL: pytest-sort-0.0.1.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for pytest-sort-0.0.1.tar.gz
Algorithm Hash digest
SHA256 52db0d4ad0381eb84e21001506ad8d9bb493539e44d03efa42c420e5c6a850bf
MD5 7a1561501638c02f78d13ffa3c8e05ec
BLAKE2b-256 f2e84b1fe5f44340bebeb4c8da8007ae2810af16f6b4165fba2aad1103751074

See more details on using hashes here.

File details

Details for the file pytest_sort-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: pytest_sort-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for pytest_sort-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9320528fbd986ddfd54992ca12c6d4523b4864c8893e5f86a04d7459488573ae
MD5 27e991a815da72f724f3b546294680a3
BLAKE2b-256 e26b550f219ba36625145ebbe19732d69c8d301e27df3f3ce843afd8d593937d

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