Skip to content

python: fix pytest-cov false warnings by compiling config scripts with full path (#27867)#28093

Merged
asmorkalov merged 1 commit intoopencv:4.xfrom
AKash-A007:fix-pytest-cov-warnings-27867
Nov 28, 2025
Merged

python: fix pytest-cov false warnings by compiling config scripts with full path (#27867)#28093
asmorkalov merged 1 commit intoopencv:4.xfrom
AKash-A007:fix-pytest-cov-warnings-27867

Conversation

@AKash-A007
Copy link
Copy Markdown
Contributor

This change fixes Issue #27867, where pytest-cov shows warnings for config.py and config-3.py after importing cv2.
The problem came from using exec() without passing the real file path, so coverage tools could not match the files correctly.

The update uses compile() with the actual path before executing the code, which removes the warnings without affecting any existing behavior.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

@asmorkalov asmorkalov merged commit 1c712fe into opencv:4.x Nov 28, 2025
47 of 51 checks passed
@asmorkalov asmorkalov mentioned this pull request Dec 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants