Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

pylint-pytest

PyPI - Version PyPI - Python Version PyPI - Downloads PyPI - License

Github - Testing codecov

Code style: black Checked with mypy Pylint Ruff

Say Thanks!

A Pylint plugin to suppress pytest-related false positives.

Installation

Requirements:

  • pylint
  • pytest>=4.6

To install:

$ pip install pylint-pytest

Usage

Enable via command line option --load-plugins

$ pylint --load-plugins pylint_pytest <path_to_your_sources>

Or in .pylintrc:

[MASTER]
load-plugins=pylint_pytest

Suppressed Pylint Warnings

unused-argument

FP when a fixture is used in an applicable function but not referenced in the function body, e.g.

def test_something(conftest_fixture):  # <- Unused argument 'conftest_fixture'
    assert True

unused-import

FP when an imported fixture is used in an applicable function, e.g.

from fixture_collections import (
    imported_fixture,
)  # <- Unused imported_fixture imported from fixture_collections


def test_something(imported_fixture):
    ...

redefined-outer-name

FP when an imported/declared fixture is used in an applicable function, e.g.

from fixture_collections import imported_fixture


def test_something(
    imported_fixture,
):  # <- Redefining name 'imported_fixture' from outer scope (line 1)
    ...

no-member

FP when class attributes are defined in setup fixtures

import pytest


class TestClass(object):
    @staticmethod
    @pytest.fixture(scope="class", autouse=True)
    def setup_class(request):
        cls = request.cls
        cls.defined_in_setup_class = True

    def test_foo(self):
        assert (
            self.defined_in_setup_class
        )  # <- Instance of 'TestClass' has no 'defined_in_setup_class' member

Raise new warning(s)

W6401 deprecated-pytest-yield-fixture

Raise when using deprecated @pytest.yield_fixture decorator (ref)

import pytest


@pytest.yield_fixture  # <- Using a deprecated @pytest.yield_fixture decorator
def yield_fixture():
    yield

W6402 useless-pytest-mark-decorator

Raise when using every @pytest.mark.* for the fixture (ref)

import pytest


@pytest.fixture
def awesome_fixture():
    ...


@pytest.fixture
@pytest.mark.usefixtures(
    "awesome_fixture"
)  # <- Using useless `@pytest.mark.*` decorator for fixtures
def another_awesome_fixture():
    ...

W6403 deprecated-positional-argument-for-pytest-fixture

Raise when using deprecated positional arguments for fixture decorator (ref)

import pytest


@pytest.fixture("module")  # <- Using a deprecated positional arguments for fixture
def awesome_fixture():
    ...

F6401 cannot-enumerate-pytest-fixtures

Raise when the plugin cannot enumerate and collect pytest fixtures for analysis

NOTE: this warning is only added to test modules (test_*.py / *_test.py)

import no_such_package  # <- pylint-pytest plugin cannot enumerate and collect pytest fixtures

Changelog

See CHANGELOG.

License

pylint-pytest is available under MIT license.

Release files for pylint-pytest 2.0.0a0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pylint-pytest 2.0.0a0
File Size Uploaded
pylint-pytest-2.0.0a0.tar.gz 13.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pylint-pytest 2.0.0a0
File Interpreter ABI Platform
pylint_pytest-2.0.0a0-py3-none-any.whl Python 3 none any Details

Total release size: 25.3 kB

Release files / pylint-pytest-2.0.0a0.tar.gz

Download URL pylint-pytest-2.0.0a0.tar.gz
Size 13.5 kB
Tags Source
SHA-256 checksum
How to use checksums
78f44012d005cc74ffe3136bcc766a8624ada17d63e47ed67c033958d49c133b
BLAKE2b-256 checksum
How to use checksums
9ed5f462966dfef323a12ebeabdaac17a7fa9265b11c7e41fcf386acd1da77d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / pylint_pytest-2.0.0a0-py3-none-any.whl

Download URL pylint_pytest-2.0.0a0-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8c2223680619f1e34a3e82cfab9c9d1fbfd0558c321c35196a74a1a4babfbf6c
BLAKE2b-256 checksum
How to use checksums
5ff8be62678ce54a1973053041e57bac00293a2bd84d26232792c4c3bb618a0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7
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