12

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)
Frozenglass
  • 145
  • 1
  • 9
  • I assume the command works on your local box? You could also try using `pytest` and not `py.test` – Matt Messersmith Dec 08 '18 at 18:30
  • nope, I get the same result no matter the machine. just tried `pytest` and got the same results :/ – Frozenglass Dec 08 '18 at 20:42
  • Does this answer your question? [Coverage.py warning: No data was collected. (no-data-collected)](https://stackoverflow.com/questions/47287721/coverage-py-warning-no-data-was-collected-no-data-collected) – louis_guitton Mar 07 '20 at 15:30

1 Answers1

18

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

Will Keeling
  • 22,055
  • 4
  • 51
  • 61