# pytest fixture remove codemod
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![codecov](https://codecov.io/gh/Klavionik/pytest-fixture-remover/graph/badge.svg?token=L5GROOX2QN)](https://codecov.io/gh/Klavionik/pytest-fixture-remover)
[![PyPI - Version](https://img.shields.io/pypi/v/pytest-fixture-remover)](https://pypi.org/project/pytest-fixture-remover)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pytest-fixture-remover)
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.
```shell
pip install pytest-fixture-remover
```
Run against your tests, specifying a fixture to remove.
```shell
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).
Raw data
{
"_id": null,
"home_page": "https://github.com/Klavionik/pytest-fixture-remover",
"name": "pytest-fixture-remover",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "Roman Vlasenko",
"author_email": "klavionik@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/86/82/a167888f4a1efd5ad4c52bb590d43c9f69a4c41dab0f2e70ca425c89933e/pytest_fixture_remover-1.0.1.post1.tar.gz",
"platform": null,
"description": "# pytest fixture remove codemod\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![codecov](https://codecov.io/gh/Klavionik/pytest-fixture-remover/graph/badge.svg?token=L5GROOX2QN)](https://codecov.io/gh/Klavionik/pytest-fixture-remover)\n[![PyPI - Version](https://img.shields.io/pypi/v/pytest-fixture-remover)](https://pypi.org/project/pytest-fixture-remover)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pytest-fixture-remover)\n\nA LibCST codemod to remove pytest fixtures applied via the `usefixtures` decorator,\nas well as its parametrizations.\n\n> [!NOTE]\n> Only fixture usage will be removed, not its definition.\n\n# Usage\nThis package requires Python >= 3.8. \n\nInstall from PyPI.\n\n```shell\npip install pytest-fixture-remover\n```\n\nRun against your tests, specifying a fixture to remove.\n\n```shell\npython -m libcst.tool codemod -x pytest_fixture_remover.RemovePytestFixtureCommand my_project_tests/ --name clean_db\n```\n\nAdd `--no-format` option to stop LibCST from running Black against modified code.\n\nBefore/after examples can be found in the `tests.test_command` module.\n\n# Note on formatting\nThis codemod assumes that the target code is formatted with Black using\nthe magic trailing comma. It **may** change the existing formatting in several ways:\n1. When removing a fixture name from the `usefixtures` call.\n2. When removing a value that parametrizes the fixture via `parametrize`.\n\nIn both cases the behavior is the same and obeys the following rules:\n1. If there's only one item left after modifying, remove the trailing comma.\n2. If there are multiple items left after modifying and the removed item was the last,\npreserve the last item's comma (or its absence).\n",
"bugtrack_url": null,
"license": "",
"summary": "A LibCST codemod to remove pytest fixtures applied via the usefixtures decorator, as well as its parametrizations.",
"version": "1.0.1.post1",
"project_urls": {
"Homepage": "https://github.com/Klavionik/pytest-fixture-remover"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2447d333e8727610d5e14c13390a637711765010fcb70c632d810de2058069c2",
"md5": "c61738ce0e5d02f35eb6bbfa78d7e0f9",
"sha256": "d7e8a8fc4213b2e32464e506c50c9c11a29508d24d06e8fbf5cc92dd9167ba5c"
},
"downloads": -1,
"filename": "pytest_fixture_remover-1.0.1.post1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c61738ce0e5d02f35eb6bbfa78d7e0f9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<4.0",
"size": 4996,
"upload_time": "2024-02-14T05:36:56",
"upload_time_iso_8601": "2024-02-14T05:36:56.487978Z",
"url": "https://files.pythonhosted.org/packages/24/47/d333e8727610d5e14c13390a637711765010fcb70c632d810de2058069c2/pytest_fixture_remover-1.0.1.post1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8682a167888f4a1efd5ad4c52bb590d43c9f69a4c41dab0f2e70ca425c89933e",
"md5": "35a81b2428ce82f946c48d0397f788cd",
"sha256": "2783377e0e1d6271eb26db2a88c413fe30de22cb37eb34a78f40a3d5a05e5748"
},
"downloads": -1,
"filename": "pytest_fixture_remover-1.0.1.post1.tar.gz",
"has_sig": false,
"md5_digest": "35a81b2428ce82f946c48d0397f788cd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<4.0",
"size": 4136,
"upload_time": "2024-02-14T05:36:57",
"upload_time_iso_8601": "2024-02-14T05:36:57.573238Z",
"url": "https://files.pythonhosted.org/packages/86/82/a167888f4a1efd5ad4c52bb590d43c9f69a4c41dab0f2e70ca425c89933e/pytest_fixture_remover-1.0.1.post1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-14 05:36:57",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Klavionik",
"github_project": "pytest-fixture-remover",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pytest-fixture-remover"
}