pylint-pytest


Namepylint-pytest JSON
Version 1.1.7 PyPI version JSON
download
home_pagehttps://github.com/pylint-dev/pylint-pytest
SummaryA Pylint plugin to suppress pytest-related false positives.
upload_time2023-12-04 07:29:49
maintainer
docs_urlNone
authorStavros Ntentos
requires_python>=3.6
licenseMIT
keywords pylint pytest plugin
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "pylint,pytest,plugin",
    "author": "Stavros Ntentos",
    "author_email": "133706+stdedos@users.noreply.github.com",
    "download_url": "https://files.pythonhosted.org/packages/aa/6e/36a916bfd251d4901ef9f5ddfece3b0e113f9109de29d962c6ea6b53cc17/pylint-pytest-1.1.7.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.7",
    "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": "981a549ecc83f626f1b99b31c7123523555c262c8678260336b0a6eb6382732e",
                "md5": "93d17b503422cbac5798ca85e6579737",
                "sha256": "5d687a2f4b17e85654fc2a8f04944761efb11cb15dc46d008f420c377b149151"
            },
            "downloads": -1,
            "filename": "pylint_pytest-1.1.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "93d17b503422cbac5798ca85e6579737",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 10750,
            "upload_time": "2023-12-04T07:29:48",
            "upload_time_iso_8601": "2023-12-04T07:29:48.749488Z",
            "url": "https://files.pythonhosted.org/packages/98/1a/549ecc83f626f1b99b31c7123523555c262c8678260336b0a6eb6382732e/pylint_pytest-1.1.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aa6e36a916bfd251d4901ef9f5ddfece3b0e113f9109de29d962c6ea6b53cc17",
                "md5": "df891fe34d8b53003c0e8c7d8431612e",
                "sha256": "7a38be02c014eb6d98791eb978e79ed292f1904d3a518289c6d7ac4fb4122e98"
            },
            "downloads": -1,
            "filename": "pylint-pytest-1.1.7.tar.gz",
            "has_sig": false,
            "md5_digest": "df891fe34d8b53003c0e8c7d8431612e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 12768,
            "upload_time": "2023-12-04T07:29:49",
            "upload_time_iso_8601": "2023-12-04T07:29:49.797612Z",
            "url": "https://files.pythonhosted.org/packages/aa/6e/36a916bfd251d4901ef9f5ddfece3b0e113f9109de29d962c6ea6b53cc17/pylint-pytest-1.1.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-04 07:29:49",
    "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"
}
        
Elapsed time: 0.14712s