A Pylint plugin to suppress pytest-related false positives.
Project description
pylint-pytest
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pylint-pytest-1.1.3rc0.tar.gz
.
File metadata
- Download URL: pylint-pytest-1.1.3rc0.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad6b236d1a21ca981622ad2191de83b70d428efe2619a4f573d73dc447800313 |
|
MD5 | 8169f3b043a2f3add578eaa54d74d1a2 |
|
BLAKE2b-256 | a48790a64c70c28b95bc70313fdf88673fb1b788f3d8e7161332bd1ddc1e17e2 |
File details
Details for the file pylint_pytest-1.1.3rc0-py2.py3-none-any.whl
.
File metadata
- Download URL: pylint_pytest-1.1.3rc0-py2.py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08b43509dd10a3623916ad310d9cea87930ef8c686c1edcf74e6c3542dfdc414 |
|
MD5 | 6a05ed3a3830056d6549deac8209aaa1 |
|
BLAKE2b-256 | 0716f4b58046dbf3c09a33454c293f87ea735c34dd050a8f0013b81cd695afa7 |