Questions tagged [python-coverage]

Coverage.py is a tool for measuring code coverage of Python programs.

Coverage.py is a tool for measuring code coverage of Python programs. It monitors your program, noting which parts of the code have been executed, then analyzes the source to identify code that could have been executed but was not.

Coverage measurement is typically used to gauge the effectiveness of tests. It can show which parts of your code are being exercised by tests, and which are not.

See https://coverage.readthedocs.io/

54 questions
66
votes
4 answers

preventing python coverage from including virtual environment site packages

I am new to coverage and ran into a strange problem. My coverage is taking my virtual environment site packages into account. Here is the output of the coverage run: coverage run…
64
votes
2 answers

How to Fix Python Nose: Coverage not available: unable to import coverage module

I can't seem to get code coverage with Nose to work, despite having the plugin installed. Any ideas on how to fix this? 12:15:25 ~/sandbox/ec$ nosetests --plugins Plugin xunit Plugin deprecated Plugin skip Plugin multiprocess Plugin…
doremi
  • 14,921
  • 30
  • 93
  • 148
33
votes
5 answers

combine python coverage files?

I'm wondering if it's possible to combine coverage.xml files into 1 file to see global report in HTML output. I've got my unit/functional tests running as 1 command and integration tests as the second command. That means my coverage for…
tunarob
  • 2,768
  • 4
  • 31
  • 48
21
votes
2 answers

Running coverage inside virtualenv

I recently stumbled upon some issue with running coverage measurements within virtual environment. I do not remember similar issues in the past, nor I was able to find solution on the web. Basically, when I am trying to run test suite in virtualenv,…
Tadeck
  • 132,510
  • 28
  • 152
  • 198
20
votes
2 answers

How to get combined code coverage over multiple runs of Python script

I've got a python program which is tested by running it several times with different inputs, and comparing the outputs against reference results. I'd like to get code coverage of all the tests combined, so I can see if there are extra sets of inputs…
xorsyst
  • 7,897
  • 5
  • 39
  • 58
17
votes
1 answer

How do I interpret Python coverage.py branch coverage results?

I'm using coverage.py to measure the code coverage of my tests. I've enabled branch coverage, but I can't quite make sense of the report. Without branch coverage, I get 100% coverage: Name Stmts Miss Cover …
David Eyk
  • 12,171
  • 11
  • 63
  • 103
11
votes
1 answer

Reporting cumulative coverage across multiple Python versions

I have code that runs conditionally depending on the current version of Python, because I'm supporting 2.6, 2.7, and 3.3 from the same package. I currently generate a coverage report like this, using the default version of Python: coverage run…
coffee-grinder
  • 26,940
  • 19
  • 56
  • 82
10
votes
1 answer

Code coverage for Jinja2 templates

I have a Pyramid web application which uses Jinja2 as template engine. It is tested using the Pyramid testing helpers together with py.test and the coverage plugin. But coverage works only for my Python code. Is there way to check also for coverage…
Achim
  • 15,415
  • 15
  • 80
  • 144
10
votes
2 answers

Python test discovery with doctests, coverage and parallelism

... and a pony! No, seriously. I am looking for a way to organize tests that "just works". Most things do work, but not all pieces fit together. So here is what I want: Having tests automatically discovered. This includes doctests. Note that the…
Helmut Grohne
  • 6,578
  • 2
  • 31
  • 67
9
votes
2 answers

python conditional coverage for subexpression

I'm trying to find a python code coverage tool which can measure if subexpressions are covered in a statement: For instance, I'd like to see if condition1/condition2/condtion3 is covered in following example? if condition1 or condition2 or…
zhutoulala
  • 4,792
  • 2
  • 21
  • 34
8
votes
3 answers

Can python coverage module conditionally ignore lines in a unit test?

Using nosetests and the coverage module, I would like coverage reports for code to reflect the version being tested. Consider this code: import sys if sys.version_info < (3,3): print('older version of python') When I test in python version 3.5,…
John
  • 1,709
  • 1
  • 24
  • 27
7
votes
1 answer

nosetests coverage including Python packages

I'm using nosetests to run a few unit tests and show me our code coverage using something like: nosetests -w ./test --with-xunit --with-coverage --cover-tests This works well except for the fact that I'm seeing a bunch of Python packages in the…
Chris Williams
  • 11,647
  • 15
  • 60
  • 97
7
votes
2 answers

Jenkins build inside a docker container with generated reports

I am new to Jenkins and Docker and even after some researches, I do not find the way to do these things. I want to : Execute pytest and python-coverage on my project inside a docker container. This should generate test and coverage reports Access…
Whin3
  • 675
  • 2
  • 9
  • 27
7
votes
2 answers

Running tests with coverage using django-jenkins

I've got a couple of Django projects that I work on, and I use Jenkins for continuous integration purposes. I've had that arrangement up and running for a while and it works well. I'd like to be able to generate automated test coverage reports and…
Matthew Daly
  • 9,212
  • 2
  • 42
  • 83
6
votes
1 answer

Python: AssertionError when running nose tests with coverage

I'm fairly green with python testing, so this might be something I'm doing wrong.. When I run my tests, the test runners works fine and coverage too.. but between the two I get an assertion error: Traceback (most recent call last): File…
h3.
  • 10,688
  • 15
  • 51
  • 54
1
2 3 4