Skip to content

Latest commit

 

History

History
32 lines (21 loc) · 447 Bytes

PT003.md

File metadata and controls

32 lines (21 loc) · 447 Bytes

PT003

scope='function' is implied in @pytest.fixture()

Fixtures with function scope should not specify scope explicitly because function scope is implied by default.

Examples

Bad code:

import pytest

@pytest.fixture(scope='function')
def my_fixture():
    ...

Good code:

import pytest

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

Rationale

  • to enforce consistency between all fixtures in a codebase