Delta5
Delta5

Reputation: 21

Cython coverage not showing properly

After any call to a Cython library, no lines show up as covered, even though I have tests that are clearly covering the library calls. I even tested this by putting in a obligatory NotImplementedError() to make sure they failed.

def build_ai_cython_widget():
  my_cython_lib.do_something()
  call_another_function()  # This is not covered

Cython doesn't include coverage information unless it's recompiled with slow coverage, but I can't do this since I don't own the library. I tried using the various ENV variables suggested by the the docs, but that did not help.

The only thing that seems to trigger it is an await, but I can't do that because my code does not support await.

Unfortunately I can't mock the underlying library since my tests would be meaningless in that case.

How do I fix this?

Upvotes: 0

Views: 45

Answers (1)

oholimoli
oholimoli

Reputation: 113

I had the same problem and found a workaround. Try to delete the .coverage file that is generated and the folder with the coverage report.

Then run the test again. The coverage report should now show everything that is covered in your tests.

Upvotes: 1

Related Questions