Skip to main content

pytest plugin to execute or ignore tests based on fixtures

Project description

pytest-filterfixtures

pytest-filterfixtures is a pytest plugin to filter tests based on their fixtures.

This is particularly useful in large test codebases when fixtures require changes/refactoring, or a specific fixture stops wokring due to external reasons. You can work on modifying the fixture(s) and have better control over which tests should run.

Installation

Install with pip

pip install pytest-filterfixtures

Usage

pytest-filterfixtures adds the following command line options:

  • --include-fixtures to execute all tests that use at least one of the specified fixtures as part of their setup/teardown
  • --exclude-fixtures to deselect all tests that use at least one of the specified fixtures as part of their setup/teardown

Example

Given the following test file

@pytest.fixture()
def fixt1():
    return 1

@pytest.fixture()
def fixt2():
    return 2

@pytest.fixture()
def fixt3(fixt1):
    return fixt1 + 1

def test1(fixt1):
    ...

def test2(fixt2):
    ...

def test3(fixt3):
    ...
  • pytest --include-fixtures fixt1 fixt2 executes test1, test2, test3
  • pytest --include-fixtures fixt3 executes test3
  • pytest --exclude-fixtures fixt1 executes test2
  • pytest --exclude-fixtures fixt3 --include-fixtures fixt1 executes test1

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_filterfixtures-0.1.0.tar.gz (1.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_filterfixtures-0.1.0-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file pytest_filterfixtures-0.1.0.tar.gz.

File metadata

  • Download URL: pytest_filterfixtures-0.1.0.tar.gz
  • Upload date:
  • Size: 1.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pytest_filterfixtures-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3530402c2ea3b9688d61815343777b41f7e4756a87b1387aa211df33871cd1af
MD5 97cb9f3ac478cc7c8f3de48ad643365f
BLAKE2b-256 bda45e6a924b4582634bbfbe3daa4a9b0bab8294393a4d7b86ac17f59cb2559f

See more details on using hashes here.

File details

Details for the file pytest_filterfixtures-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_filterfixtures-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pytest_filterfixtures-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0365adebb1875a3ba9df9f2a3de36e06ce340f8531f4575405ea1703c2e63364
MD5 e27575966d2cf0eacbdb8e47a7d9c37d
BLAKE2b-256 927818a57158b310c2a051ff59b622d03ab6e9d70f8b7d004b63e0dce928bfd0

See more details on using hashes here.

Supported by

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