A LibCST codemod to remove pytest fixtures applied via the usefixtures decorator, as well as its parametrizations.
Project description
pytest fixture remove codemod
A LibCST codemod to remove pytest fixtures applied via the usefixtures
decorator,
as well as its parametrizations.
[!NOTE] Only fixture usages 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:
- When removing a fixture name from the
usefixtures
call. - When removing a value that parametrizes the fixture via
parametrize
.
In both cases the behavior is the same and obey the following rules:
- If there's only one item left after modifying, remove the trailing comma.
- If there's multiple items left after modifying and the removed item was the last, preserve the last item's comma (or its absense).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pytest_fixture_remover-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22a702ee8edcaacefe20da7774d0bccab41aa3ed2f2c18bb1d36c195d2d4e5cf |
|
MD5 | ea54cfee91e3dd05471117721de77761 |
|
BLAKE2b-256 | 1d7dac601e9dea2697788894a98d9a00240fe4c28506403558e195325337ec01 |
Hashes for pytest_fixture_remover-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f70a766d76cde860c5f86143e01e14d0549dfb2dc0cf1e8b0a311d982f911601 |
|
MD5 | ef646a28e281db031cb8159539e753cc |
|
BLAKE2b-256 | 0e5e96cba3e8b230904c33534736642c924f78925cbe432e7638d895e3536cd0 |