Git Product home page Git Product logo

Comments (13)

dbarnett avatar dbarnett commented on May 4, 2024

Can you upload the .coverage file or provide details about where it came from? The error suggests the file is not a valid python coverage file.

from vim-coverage.

adirizka7 avatar adirizka7 commented on May 4, 2024

Sure, here is the file https://drive.google.com/file/d/1SpHT06QoMvtz13NyQkM6UeOGoDSuI25W/view?usp=sharing .
It works fine when I run coverage html tho.

from vim-coverage.

adirizka7 avatar adirizka7 commented on May 4, 2024

Looks like i figured it out, previous .coverage file was produced by using --cov-report term . I updated the args to --cov-report html and the cov.load() works fine. Thanks!

from vim-coverage.

adirizka7 avatar adirizka7 commented on May 4, 2024

oh no, it only works in separate python file

(venv) ➜  tinydb git:(master) ✗ python3
Python 3.6.11 (heads/master-dirty:86df475, Jul 31 2020, 00:00:00) 
[GCC 9.3.1 20200408 (Red Hat 9.3.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from coverage import Coverage
>>> cov = Coverage()
>>> cov.load()
>>> 

but error still occurs when running ':CoverageShow'

from vim-coverage.

dbarnett avatar dbarnett commented on May 4, 2024

And the same error from :CoverageShow, or slightly different?

Might also be room to improve that error if we can narrow down a clear failure scenario and how to detect it in our code.

from vim-coverage.

adirizka7 avatar adirizka7 commented on May 4, 2024

It was the same error. Turns out the error occurs because I forgot to activate virtualenv and I was using the older version of coverage in my os.

$ pip freeze | grep coverage
coverage==4.5.4

It's working fine when I use the newer 5.2.1 version.

can we catch this kind of error and rewrite it to a more informative error ?

from vim-coverage.

dbarnett avatar dbarnett commented on May 4, 2024

Oof, yeah, I'd hope we could detect those kinds of trivial format compatibility issues, but that error from coverage is pretty nonspecific. Do you know if there's any helper to inspect the old format or good heuristic to check for files in the old format?

from vim-coverage.

adirizka7 avatar adirizka7 commented on May 4, 2024

I've searched for the correct pytest version that produced the older format, but sadly, I couldn't find any. Best I can think of right now is to catch this error UnicodeDecodeError and rewrite it to something like coverage data is not valid, check your coverage version ....

from vim-coverage.

dbarnett avatar dbarnett commented on May 4, 2024

👍 I imagine providing a little context and trimming out some of the noise from that error would be a major improvement. In this case the one CoverageException line contains the essential info. Ideally the error would look something like
ERROR: ShowCoverage failed to read coverage file: coverage.misc.CoverageException: Couldn't read data from '/home/fedora/Desktop/GIT/tinydb/.coverage': UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf0 in position 99: invalid continuation byte.

That said, could take me quite some time to get around to submitting a fix. Contributions would be very welcome!

from vim-coverage.

adirizka7 avatar adirizka7 commented on May 4, 2024

Nice, I'll find some time to work on this one if that's ok

from vim-coverage.

dbarnett avatar dbarnett commented on May 4, 2024

Yes, that would be great!

You can include the coverage version from coverage.__version__ in the error message and just say it expected a coverage file compatible with that, check for mixed installations, and regenerate .coverage if needed. And then try to keep the original error message included in some form in case there's another cause for errors like a bug in the coverage library that the user would need to troubleshoot.

from vim-coverage.

eprigorodov avatar eprigorodov commented on May 4, 2024

Having the same issue. The traceback tells that plugin tries to read file .coverage as UTF-8 text, whereas it is actually an SQLite database:

$ file .coverage 
.coverage: SQLite 3.x database, last written using SQLite version 3022000

That is the case since coveragepy==5.0a2. The code supporting JSON format has then been removed in coveragepy==5.0a6.

Just tested that reverting to coveragepy==4.5.4 fixes the issue.

from vim-coverage.

dbarnett avatar dbarnett commented on May 4, 2024

Oh, so probably it was the same unsupported SQLite issue all along! That sounds like we could catch and give a much more user-friendly message for this case, when it hits a UnicodeDecodeError trying to decode a file that's actually SQLite.

from vim-coverage.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.