Skip to content

Latest commit

 

History

History
33 lines (23 loc) · 406 Bytes

PT020.md

File metadata and controls

33 lines (23 loc) · 406 Bytes

PT020

@pytest.yield_fixture is deprecated, use @pytest.fixture

Examples

Bad code:

import pytest

@pytest.yield_fixture()
def my_fixture():
    obj = SomeClass()
    yield obj
    obj.cleanup()

Good code:

import pytest

@pytest.fixture()
def my_fixture():
    obj = SomeClass()
    yield obj
    obj.cleanup()

Rationale

  • to avoid using the deprecated function