Skip to content

Staging integration tests require redis just to import top-level conftest #3517

@anth-volk

Description

@anth-volk

Problem

The staging integration-test job runs only deployed-service tests:

  • tests/integration/test_live_calculate.py
  • tests/integration/test_live_economy.py

But pytest still imports the top-level tests/conftest.py, and that file imports redis at module import time.

The workflow step currently installs only:

  • pytest
  • httpx

So test collection fails before any integration test runs with:

ImportError while loading conftest '/home/runner/work/policyengine-api/policyengine-api/tests/conftest.py'.
tests/conftest.py:6: in <module>
    import redis
E   ModuleNotFoundError: No module named 'redis'

Root cause

redis is only needed by the rest_client fixture, not by the deployed-service integration tests. But because it is imported eagerly at module import time, every test tier under tests/ inherits that dependency.

Fix

Import redis lazily inside the rest_client fixture so only tests that actually use that fixture require the package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions