Skip to main content

pytest fixture remove codemod

Code style: black codecov PyPI - Version PyPI - Python Version

A LibCST codemod to remove pytest fixtures applied via the usefixtures decorator, as well as its parametrizations.

[!NOTE] Only fixture usage will be removed, not its definition.

Usage

This package requires Python >= 3.8.

Install from PyPI.

pip install pytest-fixture-remover

Run against your tests, specifying a fixture to remove.

python -m libcst.tool codemod -x pytest_fixture_remover.RemovePytestFixtureCommand my_project_tests/ --name clean_db

Add --no-format option to stop LibCST from running Black against modified code.

Before/after examples can be found in the tests.test_command module.

Note on formatting

This codemod assumes that the target code is formatted with Black using the magic trailing comma. It may change the existing formatting in several ways:

  1. When removing a fixture name from the usefixtures call.
  2. When removing a value that parametrizes the fixture via parametrize.

In both cases the behavior is the same and obeys the following rules:

  1. If there's only one item left after modifying, remove the trailing comma.
  2. If there are multiple items left after modifying and the removed item was the last, preserve the last item's comma (or its absence).

Metadata

Release files for pytest-fixture-remover 1.0.1.post1

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-fixture-remover 1.0.1.post1
File Size Uploaded
pytest_fixture_remover-1.0.1.post1.tar.gz 4.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-fixture-remover 1.0.1.post1
File Interpreter ABI Platform
pytest_fixture_remover-1.0.1.post1-py3-none-any.whl Python 3 none any Details

Total release size: 9.1 kB

Release files / pytest_fixture_remover-1.0.1.post1.tar.gz

Download URL pytest_fixture_remover-1.0.1.post1.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2783377e0e1d6271eb26db2a88c413fe30de22cb37eb34a78f40a3d5a05e5748
BLAKE2b-256 checksum
How to use checksums
8682a167888f4a1efd5ad4c52bb590d43c9f69a4c41dab0f2e70ca425c89933e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.10.12 Linux/6.2.0-1019-azure

Release files / pytest_fixture_remover-1.0.1.post1-py3-none-any.whl

Download URL pytest_fixture_remover-1.0.1.post1-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d7e8a8fc4213b2e32464e506c50c9c11a29508d24d06e8fbf5cc92dd9167ba5c
BLAKE2b-256 checksum
How to use checksums
2447d333e8727610d5e14c13390a637711765010fcb70c632d810de2058069c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.10.12 Linux/6.2.0-1019-azure

Release history Release notifications | RSS feed

This release

1.0.1.post1 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

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