Skip to content

fix(tests): set OPENCV_IO_ENABLE_OPENEXR in conftest#232

Open
mountarreat wants to merge 1 commit intonikopueringer:mainfrom
mountarreat:fix/exr-test-harness
Open

fix(tests): set OPENCV_IO_ENABLE_OPENEXR in conftest#232
mountarreat wants to merge 1 commit intonikopueringer:mainfrom
mountarreat:fix/exr-test-harness

Conversation

@mountarreat
Copy link
Copy Markdown
Contributor

What does this change?

pyproject.toml sets env = ["OPENCV_IO_ENABLE_OPENEXR=1"] under
[tool.pytest.ini_options], but that option requires the pytest-env
plugin, which is not in the dev dependency group. Pytest emits
PytestConfigWarning: Unknown config option: env on every run and the
env var is never actually exported by the config declaration.

This PR replaces the inert config line with
os.environ.setdefault("OPENCV_IO_ENABLE_OPENEXR", "1") at the top of
tests/conftest.py (after imports). OpenCV reads the flag at import
time, and conftest.py only imports cv2 inside two fixtures, so the
setdefault runs before any test module brings cv2 in. setdefault
preserves the existing workflow-level export in
.github/workflows/ci.yml. No new dependencies are added.

How was it tested?

Locally on Windows with Python 3.13.11 (uv sync --group dev), with
OPENCV_IO_ENABLE_OPENEXR explicitly unset in the shell so the
conftest fix has to stand on its own:

  • uv run ruff format --check: 43 files clean
  • uv run ruff check: all checks passed
  • uv run pytest -v --tb=short -m "not gpu": 363 passed, 1 skipped
    (MLX), 4 deselected (GPU), 1 warning. The Unknown config option: env
    warning is gone; the remaining warning is an unrelated torch autocast
    note on a no-CUDA machine.
  • uv run corridorkey --help: exits 0

Checklist

  • uv run pytest passes
  • uv run ruff check passes
  • uv run ruff format --check passes

pyproject.toml declared `env = ["OPENCV_IO_ENABLE_OPENEXR=1"]` under
[tool.pytest.ini_options], but that option requires the pytest-env
plugin and that plugin is not in the dev dependency group. Pytest
therefore emitted `PytestConfigWarning: Unknown config option: env`
on every run and the config declaration never actually exported the
variable.

Replace the inert config line with an os.environ.setdefault call at
the top of tests/conftest.py, after imports. OpenCV reads the flag
at import time, and conftest.py only imports cv2 inside two fixtures,
so the setdefault runs before any test module brings cv2 in.
setdefault is used so the workflow-level export in
.github/workflows/ci.yml is preserved unchanged. No new dependencies
are added.

Verified locally on Windows with Python 3.13.11:
- uv run ruff format --check: clean
- uv run ruff check: clean
- uv run pytest -v --tb=short -m "not gpu" with OPENCV_IO_ENABLE_OPENEXR
  explicitly unset in the shell: 363 passed, 1 skipped (MLX), 4
  deselected (GPU), 1 warning. The unknown-option warning is gone;
  the remaining warning is an unrelated torch autocast note.
- uv run corridorkey --help: exits 0.
@mountarreat mountarreat marked this pull request as ready for review April 18, 2026 02:04
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.

1 participant