3

Is it possible to measure python code coverage at runtime and view the results as they are generated? I tried using coverage but couldn't find an option that would help. My initial experiments show that the .coverage file isn't saved to until the end of the programs execution, meaning we can't view the results using 'coverage html' or 'coverage report'.

5
  • Do you not have a way to end your program cleanly? Commented Jul 18, 2017 at 10:34
  • @NedBatchelder my use case is more for if I have a continuously running program like a web server and I wanted to see where my code hasn't been touched over a longer period of time Commented Jul 18, 2017 at 10:39
  • Maybe adding a way to end the server will be easier than using the coverage API in the code. Commented Jul 18, 2017 at 14:54
  • @NedBatchelder perhaps during development that would be fine. I was thinking of a production environment where interrupting the server is probably not a good idea. Perhaps I'll make a PR into coverage at some point to add this. Commented Jul 18, 2017 at 21:17
  • If you want to take it on, drop me an email so we can discuss the design. Commented Jul 19, 2017 at 1:56

1 Answer 1

3

As of version 4.4, you can call coverage.save() and continue running. This means you have to use the coverage.py API inside your program rather than just using the command-line interface.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.