All Projects → jllorencetti → Pytest Deadfixtures

jllorencetti / Pytest Deadfixtures

Licence: mit
Plugin to list unused fixtures in your tests

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Pytest Deadfixtures

pytest-datafixtures
Data fixtures for pytest made simple
Stars: ✭ 24 (-73.03%)
Mutual labels:  fixtures, pytest
lovely-pytest-docker
Pytest plugin providing the ability to use docker-compose services as fixtures.
Stars: ✭ 73 (-17.98%)
Mutual labels:  fixtures, pytest
Pytest Mimesis
Mimesis integration with the pytest test runner. This plugin provider useful fixtures based on providers from Mimesis.
Stars: ✭ 46 (-48.31%)
Mutual labels:  pytest, fixtures
Python web framework
这是一个关于python的WebUI自动化测试的项目,之前用的是unittest测试框架,现在改成pytest测试框架,Python+PageObject+Pytest
Stars: ✭ 49 (-44.94%)
Mutual labels:  pytest
Dicomweb Client
Python client for DICOMweb RESTful services
Stars: ✭ 60 (-32.58%)
Mutual labels:  pytest
Syrupy
🥞 The sweeter pytest snapshot plugin
Stars: ✭ 73 (-17.98%)
Mutual labels:  pytest
Mockwebserverplus
✔️ OkHttp mockwebserver with fixtures extension
Stars: ✭ 87 (-2.25%)
Mutual labels:  fixtures
Pytest Mypy Plugins
pytest plugin for testing mypy types, stubs, and plugins
Stars: ✭ 47 (-47.19%)
Mutual labels:  pytest
Babel Test
An opinionated library to make testing babel plugins easier.
Stars: ✭ 79 (-11.24%)
Mutual labels:  fixtures
Pytest Spec
Library pytest-spec is a pytest plugin to display test execution output like a SPECIFICATION.
Stars: ✭ 65 (-26.97%)
Mutual labels:  pytest
Wemake Django Template
Bleeding edge django template focused on code quality and security.
Stars: ✭ 1,141 (+1182.02%)
Mutual labels:  pytest
Pyautotest
Stars: ✭ 61 (-31.46%)
Mutual labels:  pytest
Flake8 Pytest Style
A flake8 plugin checking common style issues or inconsistencies with pytest-based tests.
Stars: ✭ 74 (-16.85%)
Mutual labels:  pytest
Pytest Django Queries
Generate performance reports from your django database performance tests.
Stars: ✭ 54 (-39.33%)
Mutual labels:  pytest
Node Mongodb Fixtures
🍏 Setup and tear down test fixtures with MongoDB.
Stars: ✭ 83 (-6.74%)
Mutual labels:  fixtures
Molecule Ansible Docker Aws
Example project showing how to test Ansible roles with Molecule using Testinfra and a multiscenario approach with Docker, Vagrant & AWS EC2 as infrastructure providers
Stars: ✭ 72 (-19.1%)
Mutual labels:  pytest
Education Backend
Django backend for my info-business website
Stars: ✭ 79 (-11.24%)
Mutual labels:  pytest
Wp Cli Fixtures
Easily generate custom fake data for WordPress
Stars: ✭ 65 (-26.97%)
Mutual labels:  fixtures
Pytest Grpc
Allow test gRPC with pytest
Stars: ✭ 63 (-29.21%)
Mutual labels:  pytest
Pytest Regressions
Pytest plugin for regression testing: https://pytest-regressions.readthedocs.io
Stars: ✭ 89 (+0%)
Mutual labels:  pytest

=================== pytest-deadfixtures

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg :target: https://github.com/python/black :alt: Black

.. image:: https://travis-ci.org/jllorencetti/pytest-deadfixtures.svg?branch=main :target: https://travis-ci.org/jllorencetti/pytest-deadfixtures :alt: See Build Status on Travis CI

A simple plugin to list unused or duplicated fixtures in a pytest suite.


Features

  • List unused fixtures in your tests
  • List duplicated fixtures

Installation

You can install "pytest-deadfixtures" via pip_ from PyPI_::

$ pip install pytest-deadfixtures

Usage

Important


The --dead-fixtures option will not run your tests and it's also sensible for errors in the pytest collection step. If you are using as part of you CI process the recommended way is to run it after the default test run. For example::

script:
  - pytest
  - pytest --dead-fixtures

Listing unused fixtures


Just run 'pytest' with an extra option '--dead-fixtures'::

$ pytest --dead-fixtures
============================= test session starts ==============================
(hidden for brevity)

Hey there, I believe the following fixture(s) are not being used:
Fixture name: some_fixture, location: test_write_docs_when_verbose.py:5

========================= no tests ran in 0.00 seconds =========================

Using some level of verbosity will also print the docstring of each fixture::

$ pytest --dead-fixtures -v
============================= test session starts ==============================
(hidden for brevity)

Hey there, I believe the following fixture(s) are not being used:
Fixture name: some_fixture, location: test_write_docs_when_verbose.py:5
    Blabla fixture docs

========================= no tests ran in 0.00 seconds =========================

Listing repeated fixtures


Now that you removed every unused fixture of your test suite, what if you want to go an extra mile?

An important note about this is that it uses the fixture return value to verify if two or more fixtures are equal.

This means fixtures without a truthy return value will be skipped.

You should use this as a hint only, verify that the functionality provided by both fixtures are really repeated before deleting one of them.

Just run 'pytest' with an extra option '--dup-fixtures', unlike the '--dead-fixtures' option, it'll normally run you tests::

$ pytest --dup-fixtures
======================================================================================================================== test session starts ========================================================================================================================
(hidden for brevity)

tests/test_deadfixtures.py ........

You may have some duplicate fixtures:
Fixture name: someclass_fixture, location: test_repeated_fixtures.py:12
Fixture name: someclass_samefixture, location: test_repeated_fixtures.py:17

Projects using it

  • wemake-django-template_

Contributing

Contributions are very welcome. Tests can be run with tox_, please ensure the coverage at least stays the same before you submit a pull request.

License

Distributed under the terms of the MIT_ license, 'pytest-deadfixtures' is free and open source software

Issues

If you encounter any problems, please file an issue_ along with a detailed description.

.. _@jllorencetti: https://github.com/jllorencetti .. _MIT: http://opensource.org/licenses/MIT .. _file an issue: https://github.com/jllorencetti/pytest-deadfixtures/issues .. _pytest: https://github.com/pytest-dev/pytest .. _tox: https://tox.readthedocs.io/en/latest/ .. _pip: https://pypi.python.org/pypi/pip/ .. _PyPI: https://pypi.python.org/pypi .. _wemake-django-template: https://github.com/wemake-services/wemake-django-template

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].