Skip to main content

pylint-pytest

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

Github - Testing codecov

Code style: black Ruff Checked with mypy

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.

Download files

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

Source Distribution

pylint-pytest-1.1.3.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pylint_pytest-1.1.3-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file pylint-pytest-1.1.3.tar.gz.

File metadata

  • Download URL: pylint-pytest-1.1.3.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for pylint-pytest-1.1.3.tar.gz
Algorithm Hash digest
SHA256 c12831f968973b434c1f78df6acf37b9de2f0981fadbc139942eb459a9b7bca8
MD5 41f50d7db7aa4a47c6b6b4e99b3ff57a
BLAKE2b-256 0f34cde2c3d16752069dbdeaedcb73252fbed62d28250d740b571b4470a23439

See more details on using hashes here.

File details

Details for the file pylint_pytest-1.1.3-py3-none-any.whl.

File metadata

  • Download URL: pylint_pytest-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for pylint_pytest-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 69de0dcf8fba357c47acc889bbd7eb423e58d8eab0274d0a5b61a895aff46bb9
MD5 6da65836fdb0e3e1b1983cba4479f73d
BLAKE2b-256 932256ea1a7ada24697891453cb195e6881a149fc7192e8f08a1ef1219762a45

See more details on using hashes here.

Release history Release notifications | RSS feed

1.1.8

2 files

1.1.7

2 files

1.1.6

2 files

1.1.5

2 files

1.1.4

2 files

This release

1.1.3 This release

2 files

1.1.2

1 file

1.1.1

1 file

1.1.0

1 file

1.0.3

1 file

1.0.2

1 file

1.0.1

1 file

1.0.0

1 file

0.3.0

1 file

0.2.0

1 file

0.1.2

1 file

0.1.1

1 file

0.1

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page