# pylint-pytest
![PyPI - Version](https://img.shields.io/pypi/v/pylint-pytest)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pylint-pytest)
![PyPI - Downloads](https://img.shields.io/pypi/dd/pylint-pytest)
![PyPI - License](https://img.shields.io/pypi/l/pylint-pytest)
[![Github - Testing](https://github.com/pylint-dev/pylint-pytest/actions/workflows/run-tests.yaml/badge.svg)](https://github.com/pylint-dev/pylint-pytest/actions/workflows/run-tests.yaml)
[![codecov](https://codecov.io/gh/pylint-dev/pylint-pytest/graph/badge.svg?token=NhZDLKmomd)](https://codecov.io/gh/pylint-dev/pylint-pytest)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)
[![Pylint](https://img.shields.io/badge/linting-pylint-yellowgreen)](https://github.com/pylint-dev/pylint)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Say Thanks!](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/stdedos)
A Pylint plugin to suppress pytest-related false positives.
## Installation
Requirements:
- `pylint`
- `pytest>=4.6`
To install:
```bash
$ pip install pylint-pytest
```
## Usage
Enable via command line option `--load-plugins`
```bash
$ pylint --load-plugins pylint_pytest <path_to_your_sources>
```
Or in `.pylintrc`:
```ini
[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.
```python
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.
```python
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.
```python
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
```python
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](https://docs.pytest.org/en/latest/yieldfixture.html))
```python
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](https://docs.pytest.org/en/stable/reference.html#marks))
```python
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](https://docs.pytest.org/en/stable/deprecations.html#pytest-fixture-arguments-are-keyword-only))
```python
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`)
```python
import no_such_package # <- pylint-pytest plugin cannot enumerate and collect pytest fixtures
```
## Changelog
See [CHANGELOG](CHANGELOG.md).
## License
`pylint-pytest` is available under [MIT license](LICENSE).
Raw data
{
"_id": null,
"home_page": "https://github.com/pylint-dev/pylint-pytest",
"name": "pylint-pytest",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "pylint, pytest, plugin",
"author": "Stavros Ntentos",
"author_email": "133706+stdedos@users.noreply.github.com",
"download_url": "https://files.pythonhosted.org/packages/13/b2/5d39125fedd30bfa50f755bdb30f1d5ee2ebde5f54ca7f7bc4cc4e9d51ef/pylint_pytest-1.1.8.tar.gz",
"platform": null,
"description": "# pylint-pytest\n\n![PyPI - Version](https://img.shields.io/pypi/v/pylint-pytest)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pylint-pytest)\n![PyPI - Downloads](https://img.shields.io/pypi/dd/pylint-pytest)\n![PyPI - License](https://img.shields.io/pypi/l/pylint-pytest)\n\n[![Github - Testing](https://github.com/pylint-dev/pylint-pytest/actions/workflows/run-tests.yaml/badge.svg)](https://github.com/pylint-dev/pylint-pytest/actions/workflows/run-tests.yaml)\n[![codecov](https://codecov.io/gh/pylint-dev/pylint-pytest/graph/badge.svg?token=NhZDLKmomd)](https://codecov.io/gh/pylint-dev/pylint-pytest)\n\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)\n[![Pylint](https://img.shields.io/badge/linting-pylint-yellowgreen)](https://github.com/pylint-dev/pylint)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n\n[![Say Thanks!](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/stdedos)\n\nA Pylint plugin to suppress pytest-related false positives.\n\n## Installation\n\nRequirements:\n\n- `pylint`\n- `pytest>=4.6`\n\nTo install:\n\n```bash\n$ pip install pylint-pytest\n```\n\n## Usage\n\nEnable via command line option `--load-plugins`\n\n```bash\n$ pylint --load-plugins pylint_pytest <path_to_your_sources>\n```\n\nOr in `.pylintrc`:\n\n```ini\n[MASTER]\nload-plugins=pylint_pytest\n```\n\n## Suppressed Pylint Warnings\n\n### `unused-argument`\n\nFP when a fixture is used in an applicable function but not referenced in the function body, e.g.\n\n```python\ndef test_something(conftest_fixture): # <- Unused argument 'conftest_fixture'\n assert True\n```\n\n### `unused-import`\n\nFP when an imported fixture is used in an applicable function, e.g.\n\n```python\nfrom fixture_collections import (\n imported_fixture,\n) # <- Unused imported_fixture imported from fixture_collections\n\n\ndef test_something(imported_fixture):\n ...\n```\n\n### `redefined-outer-name`\n\nFP when an imported/declared fixture is used in an applicable function, e.g.\n\n```python\nfrom fixture_collections import imported_fixture\n\n\ndef test_something(\n imported_fixture,\n): # <- Redefining name 'imported_fixture' from outer scope (line 1)\n ...\n```\n\n### `no-member`\n\nFP when class attributes are defined in setup fixtures\n\n```python\nimport pytest\n\n\nclass TestClass(object):\n @staticmethod\n @pytest.fixture(scope=\"class\", autouse=True)\n def setup_class(request):\n cls = request.cls\n cls.defined_in_setup_class = True\n\n def test_foo(self):\n assert (\n self.defined_in_setup_class\n ) # <- Instance of 'TestClass' has no 'defined_in_setup_class' member\n```\n\n## Raise new warning(s)\n\n### W6401 `deprecated-pytest-yield-fixture`\n\nRaise when using deprecated `@pytest.yield_fixture` decorator ([ref](https://docs.pytest.org/en/latest/yieldfixture.html))\n\n```python\nimport pytest\n\n\n@pytest.yield_fixture # <- Using a deprecated @pytest.yield_fixture decorator\ndef yield_fixture():\n yield\n```\n\n### W6402 `useless-pytest-mark-decorator`\n\nRaise when using every `@pytest.mark.*` for the fixture ([ref](https://docs.pytest.org/en/stable/reference.html#marks))\n\n```python\nimport pytest\n\n\n@pytest.fixture\ndef awesome_fixture():\n ...\n\n\n@pytest.fixture\n@pytest.mark.usefixtures(\n \"awesome_fixture\"\n) # <- Using useless `@pytest.mark.*` decorator for fixtures\ndef another_awesome_fixture():\n ...\n```\n\n### W6403 `deprecated-positional-argument-for-pytest-fixture`\n\nRaise when using deprecated positional arguments for fixture decorator ([ref](https://docs.pytest.org/en/stable/deprecations.html#pytest-fixture-arguments-are-keyword-only))\n\n```python\nimport pytest\n\n\n@pytest.fixture(\"module\") # <- Using a deprecated positional arguments for fixture\ndef awesome_fixture():\n ...\n```\n\n### F6401 `cannot-enumerate-pytest-fixtures`\n\nRaise when the plugin cannot enumerate and collect pytest fixtures for analysis\n\nNOTE: this warning is only added to test modules (`test_*.py` / `*_test.py`)\n\n```python\nimport no_such_package # <- pylint-pytest plugin cannot enumerate and collect pytest fixtures\n```\n\n## Changelog\n\nSee [CHANGELOG](CHANGELOG.md).\n\n## License\n\n`pylint-pytest` is available under [MIT license](LICENSE).\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Pylint plugin to suppress pytest-related false positives.",
"version": "1.1.8",
"project_urls": {
"Changelog": "https://github.com/pylint-dev/pylint-pytest/blob/master/CHANGELOG.md",
"Documentation": "https://github.com/pylint-dev/pylint-pytest#readme",
"Homepage": "https://github.com/pylint-dev/pylint-pytest",
"Say Thanks!": "https://saythanks.io/to/stdedos",
"Source": "https://github.com/pylint-dev/pylint-pytest",
"Tracker": "https://github.com/pylint-dev/pylint-pytest/issues"
},
"split_keywords": [
"pylint",
" pytest",
" plugin"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "fb34e5ef1ee982cc211d5feda95032a7f48d96542cd8985eb722f539e7b9e877",
"md5": "1591dd4b66302326af8fd4267fcb0dab",
"sha256": "8a532c1709c161406b8459bfc414c57a32a4ab488efd4bc97a22a21cb235331f"
},
"downloads": -1,
"filename": "pylint_pytest-1.1.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1591dd4b66302326af8fd4267fcb0dab",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 10761,
"upload_time": "2024-05-23T08:26:36",
"upload_time_iso_8601": "2024-05-23T08:26:36.629970Z",
"url": "https://files.pythonhosted.org/packages/fb/34/e5ef1ee982cc211d5feda95032a7f48d96542cd8985eb722f539e7b9e877/pylint_pytest-1.1.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "13b25d39125fedd30bfa50f755bdb30f1d5ee2ebde5f54ca7f7bc4cc4e9d51ef",
"md5": "dd5be60ebcd27a7628b0b330314a32c1",
"sha256": "5c862c88870aa8eb1b376df48ab9e820b5bdadfe37d965aa9ac567a6305955ca"
},
"downloads": -1,
"filename": "pylint_pytest-1.1.8.tar.gz",
"has_sig": false,
"md5_digest": "dd5be60ebcd27a7628b0b330314a32c1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 12793,
"upload_time": "2024-05-23T08:26:38",
"upload_time_iso_8601": "2024-05-23T08:26:38.292816Z",
"url": "https://files.pythonhosted.org/packages/13/b2/5d39125fedd30bfa50f755bdb30f1d5ee2ebde5f54ca7f7bc4cc4e9d51ef/pylint_pytest-1.1.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-23 08:26:38",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pylint-dev",
"github_project": "pylint-pytest",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "pylint-pytest"
}