Flagsmith / Flagsmith/flagsmith

tests: Migrate from unmaintained pytest-lazy-fixture to pytest-lazy-fixtures

Open
#7,759 0 comments 0 reactions 0 assignees View on GitHub
api
Dominant language
Python
Stars
6.6k
Forks
567
Avg merge
1d 13h
Merged PRs (30d)
121

Description

## Background

`api/pyproject.toml` currently depends on [`pytest-lazy-fixture==0.6.3`](https://pypi.org/project/pytest-lazy-fixture/), which has been unmaintained since 2020. It accesses `pytest`'s internal `CallSpec2.funcargs` attribute, which was removed in pytest 9, so the package is incompatible with pytest 8 and above:

```
ERROR tests/unit/permissions/permission_service/test_get_permitted_projects_for_user.py - AttributeError: 'CallSpec2' object has no attribute 'funcargs'
```

This was surfaced while investigating #7756 (removing the `[tool.uv].override-dependencies` block). For now, `pytest` is capped at `<8` in the `dev` extra to keep the existing tests green.

## Proposed work

Migrate the ~297 `lazy_fixture(...)` call sites in `api/tests/` to the maintained fork [`pytest-lazy-fixtures`](https://pypi.org/project/pytest-lazy-fixtures/) (note the plural), which uses a different API:

- `lazy_fixture("name")` → `lf("name")`
- New: `lfc("name", arg)` for fixture composition

Once migrated, the pytest cap can be lifted and we'll be able to take pytest 8/9 updates.

## Acceptance criteria

- [ ] Replace `pytest-lazy-fixture` with `pytest-lazy-fixtures` in `api/pyproject.toml`
- [ ] Update all call sites under `api/tests/` to the new API
- [ ] Lift the `pytest<8` cap in `api/pyproject.toml`
- [ ] Remove the TODO markers added in #7756 referencing this issue

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.