Skip to main content

pytest-select

PyPI pyversions PyPI license PyPI version CircleCI build Codecov result

This is a pytest plugin which allows to (de-)select tests by name from a list loaded from a file.

Installation

It’s recommended to install this package from PyPI:

pip install pytest-select

Usage

This plugin adds new command line options to pytest:

  • --select-from-file

  • --deselect-from-file

  • --select-fail-on-missing

The first two both expect an argument that resolves to a UTF-8 encoded text file containing one test name per line.

The third one changes the behaviour in case (de-)selected test names are missing from the to-be executed tests. By default a warning is emitted and the remaining selected tests are executed as normal. By using the --select-fail-on-missing flag this behaviour can be changed to instead abort execution in that case.

Test names are expected in the same format as seen in the output of pytest --collect-only --quiet for example.

Both plain test names or complete node ids (e.g. test_file.py::test_name) are accepted.

Example:

$~ cat selection.txt
test_something
test_parametrized[1]
tests/test_foo.py::test_other

$~ pytest --select-from-file selection.txt
$~ pytest --deselect-from-file selection.txt

Development

This package uses Poetry. To setup a development environment install Poetry and then run:

poetry install

Questions

Why not use pytest’s builtin -k option

The -k selection mechanism is (currently) unable to deal with selecting multiple parametrized tests and is also a bit fragile since it matches more than just the test name. Additionally, depending on the number of tests, giving test names on the command line can overflow the maximum command length.

What is this useful for

The author uses this plugin to split tests across workers on Circle CI.

Example:

pytest --collect-only --quiet | \
    grep '::' | \
    circleci tests split --split-by=timings --timings-type=testname > selected.txt
pytest --select-from-file selected.txt

Version History

  • v0.1.2 - 2019-01-18:
    • Add informational pytest header report output

  • v0.1.1 - 2018-12-10:
    • Add --select-fail-on-missing option

    • Add basic mutation testing

  • v0.1.0post0 - 2018-12-08:
    • Fix README

  • v0.1.0 - 2018-12-08:
    • Initial release

Metadata

Release files for pytest-select 0.1.2

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-select 0.1.2
File Size Uploaded Provenance Actions
pytest-select-0.1.2.tar.gz 4.3 kB Without provenance Details for pytest-select-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytest-select 0.1.2
File Interpreter ABI Platform Actions
pytest_select-0.1.2-py3-none-any.whl Python 3 none any Details for pytest_select-0.1.2-py3-none-any.whl

Total release size: 11.8 kB

Release files / pytest-select-0.1.2.tar.gz

Download URL pytest-select-0.1.2.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
146aaaf294034f64cc0326448d04c03fa53df197248c9874712f21a919ce414e
BLAKE2b-256 checksum
How to use checksums
74b6e9b6115204789b476aee3e7f8993d4e70c73f37f44379f555bcd83b1a63c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.10 CPython/3.6.4 Darwin/18.2.0

Release files / pytest_select-0.1.2-py3-none-any.whl

Download URL pytest_select-0.1.2-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dd4068204397efe8fcaa50f63305956f80a8ac90f4620888b7c46ebc3b00027b
BLAKE2b-256 checksum
How to use checksums
03c6f07fbbefda11038f14607d1f1ba80f9e8bdaae1a291dee04db8514b481fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.10 CPython/3.6.4 Darwin/18.2.0

Security for pytest-select 0.1.2

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.

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