Coverage.py warning: No data was collected. (no-data-collected)

I’m running into the following problem/message: Coverage.py warning: No data was collected. (no-data-collected)

When I’m in a virtual environment (locally) and execute the following line (in the project root), everything seems to work and all the reports (junit AND coverage xml/html) are generated:

python -m pytest --junitxml=test-reports/test-results.xml --cov=./ --cov-report=xml --cov-report=html

I have the exact same line in my .circleci/config.yml file wich outputs the following:

it doesn’t fail, but it doesn’t generate the .coverage file so it can’t generate the reports.

I must have something to do with the difference between the venv and circle, but i can’t seem the find out what. Has anyone experieced this before?

.circleci/config.yml

version: 2.1
orbs:
  codecov: codecov/codecov@1.0.4
jobs:
  build:
    docker:
    - image: circleci/python:3.7.3
    steps:
    - checkout
    - run:
        name: install dependencies
        command: |
          python3 -m venv venv
          . venv/bin/activate
          cd BandManager
          pip install -r requirements.txt
    - run:
        name: excute testrunner and coverage
        command: |
          . venv/bin/activate
          cd BandManager
          python -m pytest --junitxml=test-reports/test-results.xml --cov=./ --cov-report=xml --cov-report=html
    - codecov/upload:
        flags: backend

It looks like the CodeCov orb isn’t finding the test files. @thomasrockhu is this something you can assist with? :slight_smile:

Hmmm, I’m not quite sure what is happening here, but @Ewald91 would you be able to screenshot the Codecov output?

1 Like

Thanks for looking into this!

Here’s a screenshot of the Codecov output.

To me it looks like the orb does what it’s suppposed to do. There is just no coverage data.

Am i using the codecoverage correctly with Pytest when calling:
python -m pytest --junitxml=test-reports/test-results.xml --cov=./ --cov-report=xml --cov-report=html ?

1 Like

I am getting a similar problem with coverage.py. Any help?

This is the issue with new version of coverage (5.0) only, with the older version it is working fine. I am also facing the same issue. When I have downgraded it to 4.4.2 version, it is working fine.

Hi there, is this issue still open?

@Ewald91 one difference between your local venv and the CI environment could be the way that the tested Python package is installed: maybe locally it’s editable-install but on CI not. This matters for pytest-cov to determine source data (--cov option).