Skip to main content

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

Project description

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 usages will be removed, not its definition.

Usage

This package requires Python >= 3.8.

Install from PyPI into your project.

pip install pytest-fixture-remover

Run against your tests, specifying a fixture to remove.

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

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 obey the following rules:

  1. If there's only one item left after modifying, remove the trailing comma.
  2. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_fixture_remover-1.0.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

pytest_fixture_remover-1.0.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file pytest_fixture_remover-1.0.0.tar.gz.

File metadata

  • Download URL: pytest_fixture_remover-1.0.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/6.2.0-1019-azure

File hashes

Hashes for pytest_fixture_remover-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3946ef647539b8078b23b5415a3c4e425b76352059af85e17060879cff55f293
MD5 24fde87d6d1041e8d9d7d5117fce9064
BLAKE2b-256 0fc1989a1406fd95f8a14847eb10e1b06d7b7ad49e48586e10225f16c10083c1

See more details on using hashes here.

File details

Details for the file pytest_fixture_remover-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_fixture_remover-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bd5374279499aae3f6c7810d327959625573882a57313e0b922fe44ab3520eff
MD5 1cdbc0198dc6921007dc987e289b794d
BLAKE2b-256 2248c50ca221fc0953f87620663c825befe6f519617cb4e4b91df3b0dc720a65

See more details on using hashes here.

Supported by

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