pytest-cov collects no data on Travis

I recently switched from nosetests to pytest and pytest-cov for one of my Python project (

Locally, everything seemed to work fine and once on Travis, all tests passed as expected.

Yet, before the coverage report, I noticed this warning: warning: No data was collected"

and more importantly, the final coverage reported was 0% !!

I later realised that one file in the test/ directory was present locally but not in the github source code. After a commit, travis found the missing file and the coverage came back to normal.

So, this seems important for pytest-cov

Please follow and like us:
This entry was posted in Python and tagged , , . Bookmark the permalink.

11 Responses to pytest-cov collects no data on Travis

  1. hredestig says:

    Thanks man! Just hit by that one as well

  2. Dan Michael says:

    Same here. That is, it actually works fine for me locally without tests/ , and it used to do so on Travis as well. The versions of pytest etc. on Travis seems to be the same as I have locally, so I don’t really understand why it works locally and not there. Yet, adding tests/ fixed it

  3. John Didion says:

    Thanks Thomas! Just ran into this as well.

  4. glyg says:

    Thanks for the tip, helped me fix a long lasting problem…

    For info , I had to add files to all the subdirs of my test dir., e.g
    tests/submod1/, tests/submod2/ and so on.

  5. Rafid Aslam says:

    Thanks man, btw in my case, in local at first there was no, and yeah like you said the Travis-CI warns about ” warning: No data was collected”, but it worked in local.

    And then I add to my tests/ directory, and it works for either in local and travis-ci

  6. drbriefs says:

    So why is it that the pytest documentation state “You shouldn’t have files in your test directories.”?

    • locally, you should not but on travis continuous integration you should. I suspect that this is because on Travis your are installing the package from the source.
      Yet, depending on your software configuration (in your file), if you do not have an __init__, then you test directories will not be included in the source bundle downloaded by travis.

  7. azzamsa says:

    It works!. glad, thanks. 🙂

  8. azzamsa says:

    Thank you, it’s working now.

    Still wondering why some package didn’t respect PEP 420.

  9. Dan Odich says:

    you just saved my day, Huuu……..

  10. Floyd says:

    still doing the job, thanks

Leave a Reply

Your email address will not be published.