Skip to main content
Filter by
Sorted by
Tagged with
142 votes
6 answers
90k views

I'm kind of a rookie with python unit testing, and particularly coverage.py. Is it desirable to have coverage reports include the coverage of your actual test files? Here's a screenshot of my HTML ...
Kyle Fox's user avatar
  • 3,343
83 votes
15 answers
89k views

I am trying to find the coverage using the coverage module for a django project but gets Coverage.py warning: No data was collected. (no-data-collected) My project folder has src and tests folders. ...
1010101's user avatar
  • 1,021
80 votes
5 answers
141k views

I've just started using Coverage.py module and so decided to make a simple test to check how it works. Sample.py def sum(num1, num2): return num1 + num2 def sum_only_positive(num1, num2): if ...
Groosha's user avatar
  • 3,117
74 votes
4 answers
38k views

I have just started writing some unit tests for a python project I have using unittest and coverage. I'm only currently testing a small proportion, but I am trying to work out the code coverage I run ...
user avatar
72 votes
5 answers
57k views

How do I exclude entire files from coverage.py reports? According to the documentation you can exclude code by matching lines. I want to exclude entire files, so that the reports don't include 3rd ...
flybywire's user avatar
  • 276k
68 votes
4 answers
29k views

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 test.py ................
Johannes Maria Frank's user avatar
67 votes
3 answers
194k views

Context I am updating an inherited repository which has poor test coverage. The repo itself is a pytest plugin. I've changed the repo to use tox along with pytest-cov, and converted the "raw"...
Thomas Thorogood's user avatar
64 votes
2 answers
21k views

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 ...
doremi's user avatar
  • 15.4k
59 votes
4 answers
15k views

I have an abstract base class along the lines of: class MyAbstractClass(object): __metaclass__ = ABCMeta @abstractproperty def myproperty(self): pass But when I run nosetests (which ...
Demian Brecht's user avatar
49 votes
5 answers
35k views

For Jedi we want to generate our test coverage. There is a related question in stackoverflow, but it didn't help. We're using py.test as a test runner. However, we are unable to add the imports and ...
Dave Halter's user avatar
  • 16.5k
47 votes
5 answers
37k views

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 ...
tunarob's user avatar
  • 3,088
38 votes
5 answers
44k views

I ran a sample code from this thread. How to properly use coverage.py in Python? However, when I executed this command py.test test.py --cov=sample.py it gave me a warning, therefore, no report was ...
pypabot's user avatar
  • 381
37 votes
1 answer
14k views

The documentation of coverage.py says that Many people choose to use the pytest-cov plugin, but for most purposes, it is unnecessary. So I would like to know what is the difference between these two? ...
yosra's user avatar
  • 1,122
35 votes
3 answers
11k views

I use coveralls in combination with coverage.py to track python code coverage of my testing scripts. I use the following commands: coverage run --parallel-mode --source=mysource --omit=*/stuff/idont/...
SmCaterpillar's user avatar
33 votes
4 answers
24k views

I got a python script which takes command line arguments, working with some files. I'm writing succeeding tests with py.test putting this script through its paces, executing it with subprocess.call. ...
Christoph's user avatar
  • 5,652
31 votes
6 answers
9k views

I use coverage.py to check the test coverage of my django application. However since I use South for my database migrations, all those files show up with 0% and mess up the overall percentage. I ...
Jonas Obrist's user avatar
28 votes
2 answers
16k views

I'm having a weird problem with tox, py.test, coverage and pytest-cov: when py.test with the --cov option is launched from tox, it seems to require an __init__.py file in the tests folder which is not ...
aldanor's user avatar
  • 3,491
28 votes
1 answer
22k views

I am using coverage.py to get the test coverage of the code. Suppose I have two functions with the same name in two different modules # foo/foo.py def get_something(): # fetch something # 10 ...
JPG's user avatar
  • 89.4k
27 votes
2 answers
4k views

I've started working on a project with loads of unused legacy code in it. I was wondering if it might be possible to use a tool like coverage in combination with a crawler (like the django-test-utils ...
Ludo's user avatar
  • 2,839
26 votes
1 answer
3k views

I should know the answer to this, but I don't: if you try to measure the coverage of a Django project like this: coverage run manage.py runserver you get coverage measurement that misses all of your ...
Ned Batchelder's user avatar
24 votes
3 answers
10k views

I've been using the following command to run tests and evaluate code coverage for a Python project for over a year now. nosetests -v --with-coverage --cover-package=genhub genhub/*.py The coverage ...
Daniel Standage's user avatar
24 votes
5 answers
9k views

I have a .coveragerc file in the root of my project. It tells coverage.py to omit my project's migrations directories: [run] omit = *migrations* When I run coverage.py at the command line, the config ...
coffee-grinder's user avatar
23 votes
5 answers
17k views

I'm using the python coverage tool to run my unit test. As you can see from the result, it includes all the "site-packages". How can I exclude them from the report? I only want to show the report for ...
user1187968's user avatar
  • 8,146
23 votes
2 answers
8k views

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, ...
Tadeck's user avatar
  • 138k
23 votes
1 answer
28k views

I searched for a long time and surprisingly found no satisfactory answer. I have multiple modules/files in my Python project that I wrote unit tests for using unittest. The structure is such that I ...
JohnGalt's user avatar
  • 917
23 votes
5 answers
16k views

I am trying to show a coverage badge for a Python project in a private Gitlab CE installation (v11.8.6), using coverage.py for Python. However, the badge always says unknown. This is the relevant job ...
Carsten's user avatar
  • 2,092
22 votes
3 answers
37k views

sample.py def sum(num1, num2): return num1 + num2 def sum_only_positive(num1, num2): if num1 > 0 and num2 > 0: return num1 + num2 else: return None test_sample.py ...
Anilkumar Pathapati's user avatar
22 votes
3 answers
7k views

I'm trying to switch PublishCodeCoverageResults from @1 to @2. Because appeared warnig in pipeline ##[warning]New V2 version of task publishing code coverage results is available to all our customers ...
Eugene's user avatar
  • 221
21 votes
2 answers
2k views

I've written a python module, much of which is wrapped in @numba.jit decorators for speed. I've also written lots of tests for this module, which I run (on Travis-CI) with py.test. Now, I'm trying ...
Mike's user avatar
  • 20.4k
20 votes
2 answers
9k views

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 ...
xorsyst's user avatar
  • 8,287
20 votes
3 answers
5k views

I have a multi processed web server with processes that never end, I would like to check my code coverage on the whole project in a live environment (not only from tests). The problem is, that since ...
Maxim Dunavicher's user avatar
20 votes
1 answer
2k views

I want to get coverage information of a Cython module using some (unit) tests written in Python. What I have right now is coverage of the tests themselves, i.e. which lines of the tests are executed ...
mattmilten's user avatar
  • 6,796
19 votes
4 answers
31k views

I have a directory tests that includes a lot of different tests named test_*. I tried to run coverage run tests but it doesn't work. How can I run a single command to coverage multiple files in the ...
pythad's user avatar
  • 4,297
19 votes
4 answers
7k views

I am running the following through a Makefile: NPROCS:=$(shell /usr/bin/nproc) .PHONY: coverage-app coverage-app: coverage erase --rcfile=./.coveragerc-app coverage run --parallel-mode --...
Sardathrion - against SE abuse's user avatar
19 votes
1 answer
13k views

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 ...
David Eyk's user avatar
  • 12.7k
18 votes
3 answers
13k views

AFAIK the feature "test coverage" is only available in the professional version (code-coverage). How to see code coverage of my tests with the PyCharm community version?
guettli's user avatar
  • 27.7k
18 votes
2 answers
5k views

My tests clearly execute each function, and there are no unused imports either. Yet, according to the coverage report, 62% of the code was never executed in the following file: Can someone please ...
Marlyyy's user avatar
  • 722
18 votes
2 answers
1k views

Up to now the coverage in Python binary: A line was executed or not. Is there a way to get per python code line a lists of tests which execute this line? I read the coverage docs, but could not find ...
guettli's user avatar
  • 27.7k
17 votes
3 answers
5k views

I have a python project where I use: pipenv tox pytest and many more. Basically, I want to add tox to my gitlab pipelines. And almost everything seems to work, calling mypy, flake8 or black from tox ...
dabljues's user avatar
  • 1,997
17 votes
4 answers
9k views

https://coverage.readthedocs.io/en/coverage-4.5.1a/source.html#source My coverage is also including “venv” folder and I would like to exclude it no matter what I do even with --include or omit ...
Radek's user avatar
  • 1,189
17 votes
1 answer
4k views

How do I get code coverage out of a Django project's view code (and code called by view code)? coverage gunicorn <params> does not show any lines being hit.
Kimvais's user avatar
  • 39.9k
16 votes
2 answers
2k views

Is there a way to get relative paths to resulted coverage.xml (or strip off prefix) using coverage.py?
user2965111's user avatar
15 votes
3 answers
21k views

I use nosetest's coverage.py plugin. Is it somehow possible to exclude entire files or folders from the coverage report? My use case is having an external library in my project folder that obviously ...
Nova's user avatar
  • 2,668
14 votes
3 answers
10k views

I have a Python project and a tests task, set up to run pytest from the project's working directory. Doing Run 'tests' with coverage from the Run menu successfully runs the tests, and the console ...
James Hiew's user avatar
  • 7,357
14 votes
2 answers
17k views

Using coverage with pytests is a very useful tool. Html reporting allows for nice output, however through command line, can't find an option to modify the default output directory (htmlcov) example ...
Efren's user avatar
  • 4,997
13 votes
3 answers
31k views

I'm using the python coverage.py to create a very basic test suite with coverage. Currently everything works great. However, my coverage report includes all the /usr/local/lib libraries that are ...
jsookiki's user avatar
  • 542

1
2 3 4 5
11