pytest-dev / pytest-cov

Coverage plugin for pytest.
MIT License
1.76k stars 212 forks source link

No such table: tracer #385

Closed nairraghav closed 2 years ago

nairraghav commented 4 years ago

Hi,

I am seeing an error with the coverage dependency and am being forced to manually pin my version of coverage to fix the issue:

When I don't pin a coverage version, pytest-cov will find the latest coverage dependency and fails to generate a coverage file. I get the following warning:

----------- coverage: platform linux, python 3.6.5-final-0 -----------

=============================== warnings summary========================= Failed to generate report: Couldn't use data file '/home/jenkins/workspace/.../coverage-report.xml': no such table: tracer

As mentioned previously, my workaround is to pin coverage itself: coverage==4.5.4

Would you be able to specifically pin your dependencies further?

Thanks, Ron

nairraghav commented 4 years ago

For reference, I am running the following command:

python3 -m pytest --junitxml=junit_test_report.xml \ --cov-config .coveragerc \ --cov-report xml:coverage-report.xml \ --cov=lib/workflows \ tests/

nedbat commented 4 years ago

We are not going to pin the version of coverage. This is not a fundamental incompatibility. Something in your scenario is causing the failure in coverage. Can you give us a way to reproduce the problem? We'd like to fix it.

sylvainOL commented 4 years ago

Hello, I've actually the same issue. this one is without coverage in test_requirelist: https://gitlab.com/Orange-OpenSource/lfn/onap/python-onapsdk/-/jobs/589542003#L1146 this one is with coverage=4.5.4 in test_requirelist: https://gitlab.com/Orange-OpenSource/lfn/onap/python-onapsdk/-/jobs/589552578#L1140

Nestor10 commented 3 years ago

changed report name from coverage-report.xml to cov.xml and it fixed my issue.

begoldsm commented 3 years ago

@Nestor10 I tried the same and the issue still manifests using latest coverage package (5.5):

WARNING: Failed to generate report: Couldn't use data file '/cov.xml': no such table: tracer

Do we have any more updates on this? I am still pinning to 4.5.4 coverage until this is resolved.

OpaqueOrangutan commented 2 years ago

I ran into this issue as well and was able to resolve it. It's not a problem with pytest-cov, it can be reproduced locally with coverage and make. I had a make recipe something like:

coverage xml -o $(COVERAGE_FILE)

That I would run after coverage run and for whatever reason, when setting COVERAGE_FILE outside of make, I'd get the no such table: tracer error. Took me a while to figure out since I was running this from Jenkins.

mackenzieATA commented 2 years ago

I also ran into this issue - the problem is that coverage optionally uses the environment variable COVERAGE_FILE to specify where it stored execution data - https://coverage.readthedocs.io/en/6.4.1/cmd.html#data-file

Example:

# Broken
COVERAGE_FILE=out.xml bash -c 'pytest --cov --cov-report=xml:"$COVERAGE_FILE"'
> Couldn't use data file ... no such table: tracer

# Working
C_F=out.xml bash -c 'pytest --cov --cov-report=xml:"$C_F"'
> Coverage XML written to file out.xml

The fix, DON'T use the environment variable COVERAGE_FILE as where you want your report to go to, use any other name!

nairraghav commented 2 years ago

Thank you @OpaqueOrangutan & @mackenzieATA! We are no longer using the COVERAGE_FILE environment variable and no longer saw the issue.