Skip to main content

Test-ordering plugin for pytest

Project description

A pytest plugin for ensuring tests within a class are run in source order.


Release tarballs will be made available for download from Pagure Releases:

You can also install using pip:

The plugin is also available in Fedora repositories as python3-pytest-sourceorder.


When installed, test classes marked @pytest_sourceorder.ordered will have tests tun in the order of their definition.

Methods are ordered by line nuber of their definition, so spreading them between multiple files or otherwise defining them outside of their class might cause the plugin to order them wrong.

When inheriting from an ordered test class, the superclass’ methods will be run first (even if overridden), followed by the ones from subclasses. You generally do not want to apply an additional @ordered decorator to the subclasses – doing so will reset the inheritance-based ordering.


The project is happy to accept patches! Please file any patches as Pull Requests on the project’s Pagure repo. Any development discussion should be in Pagure Pull Requests and Issues.


v0.6 (2021-09-01)

  • Added support for decorated methods (thanks to Sergey Orlov)

v0.5.1 (2017-04-11)

Packaging improvements only

v0.5 (2016-01-26)

  • Added support for parametrized tests under Python 3

v0.4 (2015-01-26)

  • Python 3 compatibility

Project details

Download files

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

Source Distributions

No source distribution files available for this release. See tutorial on generating distribution archives.

Built Distribution

pytest_sourceorder-0.6.0-py2.py3-none-any.whl (16.2 kB view hashes)

Uploaded py2 py3

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