Skip to content

Latest commit

 

History

History
39 lines (27 loc) · 711 Bytes

PT001.md

File metadata and controls

39 lines (27 loc) · 711 Bytes

PT001

use @pytest.fixture() over @pytest.fixture

Configuration

  • pytest-fixture-no-parentheses
    Boolean flag specifying whether @pytest.fixture() without parameters should have parentheses.
    If the option is set to false (the default), @pytest.fixture() is valid and @pytest.fixture is an error.
    If set to true, @pytest.fixture is valid and @pytest.fixture() is an error.

Examples

Bad code (assuming pytest-fixture-no-parentheses set to false):

import pytest

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

Good code:

import pytest

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

Rationale

  • to enforce consistency between all fixtures in a codebase