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

1

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)
Argybargy answered 8/12, 2018 at 5:24 Comment(3)
I assume the command works on your local box? You could also try using pytest and not py.testCypsela
nope, I get the same result no matter the machine. just tried pytest and got the same results :/Argybargy
Does this answer your question? Coverage.py warning: No data was collected. (no-data-collected)Degeneration
G
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

Grover answered 9/12, 2018 at 20:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.