Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

codecov unable to collect data using pytest - "Coverage.py warning: No data was collected."

I'm trying to setup codecov on my public travis repo and so far haven't been able to successfully generate a report and upload it to codecov.io. I appear to receive an erroneous report in terminal that says 0% of my code is covered along with a warning.

as far as I can tell, my .travis.yml and shell script are perfectly inline with the conventions specified in pytest-cov and codecov's documentation.

my travis terminal containing the full log is here: https://www.travis-ci.com/jmaggio14/imagepypelines/jobs/163802897#L681

my repo can be found here: https://github.com/jmaggio14/imagepypelines/tree/89a6bbc2fadc94a51570d80be356941df1a87a87

my (shortened) .travis.yml file is as follows:

 sudo: false

  language: python

  python:
      - 2.7
      - 3.4
      - 3.5
      - 3.6

  install:
    # I removed some other lines for readability here
    - pip install codecov pytest-cov hypothesis

  script:
    # running tests and code coverage report
    - py.test --cov=imagepypelines tests/


  after_success:
    - codecov

I end up recieving the following warning and a message saying that 0% of my code is covered by my tests

Coverage.py warning: No data was collected. (no-data-collected)
like image 248
Frozenglass Avatar asked Dec 08 '18 05:12

Frozenglass


1 Answers

I reproduced this issue running your tests locally and discovered that coverage needs the tests folder to contain an __init__.py before it will collect any data.

I added __init__.py to the tests folder and then coverage collected the data as expected.

enter image description here

like image 170
Will Keeling Avatar answered Oct 31 '22 18:10

Will Keeling