Python icon indicating copy to clipboard operation
Python copied to clipboard

`pytest` warnings in builds

Open tianyizheng02 opened this issue 1 year ago • 7 comments

Repository commit

Doesn't matter

Python version (python --version)

Python 3.12.0, the current version used in builds

Dependencies version (pip freeze)

Doesn't matter

Expected behavior

pytest runs with no (internal) warnings

Actual behavior

Every build (see our Actions tab) has the following warnings:

/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/coverage/report_core.py:115: CoverageWarning: Couldn't parse '/home/runner/work/Python/Python/config-3.py': No source for code: '/home/runner/work/Python/Python/config-3.py'. (couldnt-parse)
  coverage._warn(msg, slug="couldnt-parse")
/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/coverage/report_core.py:115: CoverageWarning: Couldn't parse '/home/runner/work/Python/Python/config.py': No source for code: '/home/runner/work/Python/Python/config.py'. (couldnt-parse)
  coverage._warn(msg, slug="couldnt-parse")

I don't know what files these are, and I don't know what's causing these warnings to occur.

tianyizheng02 avatar Oct 15 '23 21:10 tianyizheng02

Okay so I spent good time understanding the issue and I have come to the conclusion that it is an issue with the Python\compression\peak_signal_to_noise_ratio.py file.

It arises due to the cv2 library. cv2 uses a config file for its operations. These files are config-3.py and config.py. The coverage module considers it a python file for which code coverage has to be checked, but its not actually a Python file but a configuration file. Thats what generates a warning.

SOBAN50 avatar Oct 17 '23 13:10 SOBAN50

There are multiple solutions to this:

  • Leave it as it as because its just a warning and does not break any code functionality.
  • Consider using the PILLOW package instead of CV2.

SOBAN50 avatar Oct 17 '23 13:10 SOBAN50

Okay so I spent good time understanding the issue and I have come to the conclusion that it is an issue with the Python\compression\peak_signal_to_noise_ratio.py file.

It arises due to the cv2 library. cv2 uses a config file for its operations. These files are config-3.py and config.py. The coverage module considers it a python file for which code coverage has to be checked, but its not actually a Python file but a configuration file. Thats what generates a warning.

I tried to implement the code without using any external libraries, it seems that the warnings still popup.

Saswatsusmoy avatar Oct 21 '23 03:10 Saswatsusmoy

@Saswatsusmoy I have tried using the code just by commenting out the CV2 part. No warnings pop up in my case.

SOBAN50 avatar Oct 21 '23 04:10 SOBAN50

To reiterate, we are talking about the warnings in the PyTest Code Coverage part.

SOBAN50 avatar Oct 21 '23 04:10 SOBAN50

CoverageWarning indicating that coverage couldn't parse or locate source code for specified files like config-3.py and config.py, you should first confirm that the file paths are accurate, validate that the source code files exist in your project directory, ensure they are in paths covered by the analysis, and check your coverage configuration (e.g., .coveragerc) to include the relevant source paths. Double-check that you are running tests or coverage analysis from the correct directory where the source files reside, check for file permission issues, update coverage, and verify the Python environment setup. If problems persist, review filenames for typos or case sensitivity and consider seeking assistance from your development team or relevant forums.

pratyakshsuri2003 avatar Oct 26 '23 01:10 pratyakshsuri2003

Okay so I spent good time understanding the issue and I have come to the conclusion that it is an issue with the Python\compression\peak_signal_to_noise_ratio.py file.

It arises due to the cv2 library. cv2 uses a config file for its operations. These files are config-3.py and config.py. The coverage module considers it a python file for which code coverage has to be checked, but its not actually a Python file but a configuration file. Thats what generates a warning.

SOBAN50 avatar Oct 26 '23 08:10 SOBAN50