Skip to content

fxref broken in pytest >=8.4.0?Β #364

@steven-murray

Description

@steven-murray

Hi, my test files all of a sudden started failing on test collection. This seems to have happened when pytest was upgraded from 8.3.0 to 8.4.0. An example MWE:

from pytest_cases import fixture_ref as fxref
from pytest_cases import parametrize
import pytest

@pytest.fixture(scope="module")
def case_a():
    """Default frequencies."""
    return 3


@pytest.fixture(scope="module")
def case_b():
    """Default frequencies."""
    return 4

@parametrize(
    'fxt', [fxref(case_a), fxref(case_b)]
)
def test_temp(fxt):
    """Test that uses the fixture."""
    assert fxt in [3, 4], f"Expected 3 or 4, got {fxt}"

This fails with the following error for me:

______________________________________________________________________ ERROR collecting tests/test_temp.py ______________________________________________________________________
tests/test_temp.py:17: in <module>
    'fxt', [fxref(case_a), fxref(case_b)]
            ^^^^^^^^^^^^^
../.venv/lib/python3.12/site-packages/pytest_cases/fixture_parametrize_plus.py:162: in __init__
    self.fixture = get_fixture_name(fixture)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
../.venv/lib/python3.12/site-packages/pytest_cases/common_pytest.py:175: in get_fixture_name
    assert_is_fixture(fixture_fun)
../.venv/lib/python3.12/site-packages/pytest_cases/common_pytest.py:158: in assert_is_fixture
    raise ValueError("The provided fixture function does not seem to be a fixture: %s. Did you properly decorate "
E   ValueError: The provided fixture function does not seem to be a fixture: <pytest_fixture(<function case_a at 0x7f56a264bb00>)>. Did you properly decorate it ?
============================================================================ short test summary info ============================================================================
ERROR tests/test_temp.py - ValueError: The provided fixture function does not seem to be a fixture: <pytest_fixture(<function case_a at 0x7f56a264bb00>)>. Did you properly decorate it ?

I'm using pytest-cases v3.8.6.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions