Skip to content

fix(dev): add pytest-env so EXR tests pass locally without exporting env vars - #247

Merged
nikopueringer merged 1 commit into
nikopueringer:mainfrom
alexandremendoncaalvaro:fix/pytest-env-dev-dep
May 1, 2026
Merged

nikopueringer merged 1 commit into
nikopueringer:mainfrom
alexandremendoncaalvaro:fix/pytest-env-dev-dep

Conversation

@alexandremendoncaalvaro

@alexandremendoncaalvaro alexandremendoncaalvaro commented May 1, 2026 •

Copy link
Copy Markdown
Contributor

What this fixes

Closes #242.

pyproject.toml already declares:

[tool.pytest.ini_options]
env = ["OPENCV_IO_ENABLE_OPENEXR=1"]

…but the env key is provided by the third-party pytest-env plugin, and that plugin is not in [dependency-groups].dev. After a fresh uv sync --group dev, pytest emits

PytestConfigWarning: Unknown config option: env

…and the env var is never set. tests/test_clip_manager.py::TestVideoMaMa::test_videomama_exr_gamma_handling then fails with:

cv2.error: imgcodecs: OpenEXR codec is disabled. You can enable it via 'OPENCV_IO_ENABLE_OPENEXR' option.

CI passes because .github/workflows/ci.yml:12 exports OPENCV_IO_ENABLE_OPENEXR=1 on the runner — that masked the gap. Anyone running pytest locally without that env var trips it.

The change

One line in pyproject.toml plus the resulting uv.lock regeneration:

-dev = ["pytest", "pytest-cov", "ruff", "hypothesis"]
+dev = ["pytest", "pytest-cov", "pytest-env", "ruff", "hypothesis"]

I also added a short comment above the line explaining why the plugin is required so the next maintainer doesn't trim it as a "redundant" dep.

How I verified

  1. On main, with no env var exported:

    pytest tests/test_clip_manager.py::TestVideoMaMa::test_videomama_exr_gamma_handling
    

    → fails with the OpenEXR error.

  2. On this branch, after uv pip install pytest-env into my dev venv, with no env var:

    pytest tests/test_clip_manager.py::TestVideoMaMa::test_videomama_exr_gamma_handling
    

    → passes. Plugin list now shows env-1.6.0.

Why this is its own PR (not bundled with #241)

#241 (CorridorKeyBlue feature) intentionally avoided modifying dev tooling. This is dev-environment infrastructure with zero behavioural impact on the runtime — easier to review and revert independently if needed.

Test plan

  • uv sync --group dev installs pytest-env cleanly (verified via lock diff).
  • Previously-failing EXR test passes without exporting env vars.
  • CI still passes (no behaviour change for the workflow's already-exported env var).

`pyproject.toml` already declares the env var that any EXR-touching test
needs, but it lives under `[tool.pytest.ini_options].env`, which is a
key provided by the third-party `pytest-env` plugin. The plugin was not
in the dev dependency group, so a fresh `uv sync --group dev` install
shipped without it. Locally pytest emitted

    PytestConfigWarning: Unknown config option: env

…and `tests/test_clip_manager.py::TestVideoMaMa::test_videomama_exr_gamma_handling`
failed with `OpenEXR codec is disabled`. CI didn't catch it because
`.github/workflows/ci.yml:12` exports the env var on the runner, masking
the missing plugin.

Adding `pytest-env` makes the local pytest run match the CI behaviour
without anyone having to remember to export `OPENCV_IO_ENABLE_OPENEXR`.

Verified by uninstalling the env var locally, running pytest, and watching
the previously-failing test go green.
@nikopueringer
nikopueringer merged commit 56f5f67 into nikopueringer:main May 1, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(dev): add pytest-env so OPENCV_IO_ENABLE_OPENEXR is set in local pytest runs

2 participants