Skip to content

Fails with pytest >= 8.4 #9

@eldjh3

Description

@eldjh3

This is due to internal changes in pytest introduced in pytest-dev/pytest#12473. The representation of a fixture is changed to a class FixtureFunctionDefinition rather than a simple callable. A check is added in _pytest/fixtures.py (FixtureManager.parsefactories) during fixture registration that ensures a fixture is derived from this type. As this is not the case for fixtures generated by pytest-lambda they fail to be registered.

Tests fail as a result with missing fixture errors.

        for name in dir(holderobj):
            # The attribute can be an arbitrary descriptor, so the attribute
            # access below can raise. safe_getattr() ignores such exceptions.
            obj_ub = safe_getattr(holderobj_tp, name, None)
            if type(obj_ub) is FixtureFunctionDefinition:                           # <-- Additional check
                marker = obj_ub._fixture_function_marker
                if marker.name:
                    fixture_name = marker.name
                else:
                    fixture_name = name

                # OK we know it is a fixture -- now safe to look up on the _instance_.
                try:
                    obj = getattr(holderobj, name)
                # if the fixture is named in the decorator we cannot find it in the module
                except AttributeError:
                    obj = obj_ub

                func = obj._get_wrapped_function()

                self._register_fixture(
                    name=fixture_name,
                    nodeid=nodeid,
                    func=func,
                    scope=marker.scope,
                    params=marker.params,
                    ids=marker.ids,
                    autouse=marker.autouse,
                )

The new type is internal and is not exposed in the pytest namespace.
As part of the change, the internal _PytestWrapper type has been removed too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions