Skip to content

Conversation

@ruck94301
Copy link
Contributor

Use an improved approach to suppress cv2 coverage warning.

Previously, avoided nuisance warnings during static analysis with pytest
"coverage" reporting by suppressing the import of opencv-python during
pytest, using an environment variable setting that detectron2 honors.

With this PR, revert to normal import of cv2 (that is, opencv-python),
and use a better workaround to suppress the two coverage warnings, namely
filterwarnings via setting in pytest.ini.

Also pytest related,
remove John's misguided unit test which attempts to produce an
import-duration.

  1. It doesn't work reliably, because the result can be improved by
    performing another test case earlier in the pytest session, if the
    other test case loads libraries... which means this test case
    doesn't lose time loading.
  2. It's not necessary. To get a measure of import duration, use
    python's "-X importtime". This is a feature introduced in
    Python 3.7.
    Documented in new
    LabGym/tests/Notes.importtime.txt

@yujiahu415 yujiahu415 merged commit e7f79b3 into umyelab:master Oct 11, 2025
4 checks passed
@ruck94301 ruck94301 deleted the pytest-cov-suppress-cv2-coverage-warning branch October 11, 2025 15:16
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.

2 participants