Skip to content

Latest commit

 

History

History
42 lines (30 loc) · 708 Bytes

PT025.md

File metadata and controls

42 lines (30 loc) · 708 Bytes

PT025

pytest.mark.usefixtures has no effect on fixtures

Examples

Bad code:

import pytest

@pytest.fixture()
def a():
  pass

@pytest.mark.usefixtures('a')
@pytest.fixture()
def b():
  pass

Good code:

import pytest

@pytest.fixture()
def a():
  pass

@pytest.fixture()
def b(a):
  pass

Rationale

  • according to the pytest docs on pytest.mark.usefixtures:

    Also note that this mark has no effect when applied to fixtures.

  • pytest does not raise any error or warning when fixtures are decorated with pytest.mark.usefixtures, which can lead to incorrect results and broken tests