546 questions
0
votes
0
answers
1k
views
Coverage Module Not Found
I am trying to run coverage on a django project inside of a virtual environment and am having some issues with ModuleNotFoundError. As per this answer I have installed coverage inside of the virtual ...
1
vote
0
answers
1k
views
pytest-cov not generate report with new coverage version 5.X, works with coverage version 4.4.2
I have project which tox.ini as below
[tox]
envlist = unittest,functional,lint
skipsdist = True
sitepackages = False
[testenv]
setenv =
TESTING = True
deps=
-rrequirements.txt
-rtox-...
2
votes
2
answers
724
views
Coveralls UnicodeDecodeError
I have the following configuration in tox:
[tox]
envlist = py37
[testenv]
passenv = TRAVIS TRAVIS_*
setenv =
DEFAULT_FROM = [email protected]
DEFAULT_SERVER = mock_server
basepython =
...
0
votes
1
answer
373
views
coverage.py: Why the expected lines are not marked green in html report?
Sample code:
#!/usr/bin/env python
import os
import sys
from coverage import Coverage
class Cover_Diy(object):
def cover_diy(self, cmd):
if cmd == "hostname":
os.system(cmd)
...
1
vote
1
answer
1k
views
Run test and collect the coverage report using a single command
I am using Coverage.py package to collect the coverage report.
For now, I am collect the coverage report by running two commands like below:
venv) ☁ python-codelab [master] ⚡ coverage run /Users/...
4
votes
0
answers
3k
views
Django & coverage - .coveragerc omit not working
I have a Django project with multiple applications. In one application, I have a library already tested using unittest + coverage.
When I run the test of the django project, I would like to omit this ...
4
votes
4
answers
948
views
Python Coverage for C++ PyImport
Situation:
I'm attempting to get coverage reports on all python code in my current project. I've utilized Coverage.py with great success for the most part. Currently I'm using it like this taking ...
1
vote
0
answers
443
views
Getting incorrect coverage report for no matter what module we are executing on multiprocess product
We have a product with multiple python scripts which executes as different processes, sub-processes, daemons and on apache using mod-wsgi. The product runs on top of debian 9 and the scripts are ...
2
votes
1
answer
743
views
Write unit test for checking code coverage in python
I need to write test using unittest in python that fails when coverage is less than 50 percent.
Such as:
class ExampleTest(unittest.TestCase):
def setUp(self):
cov = coverage.Coverage()
cov....
1
vote
1
answer
1k
views
How to exclude directory in coverage for Python multi-module
I've project whose directory structure looks like below
ProjectRoot
- Module1
src/
tests/
- Module2
src/
tests/
...
From the root directory I want to run ...
2
votes
0
answers
410
views
lines not cover by coverage report in python3 Flask, unittest and cntext.py in test directory
When I run the command coverage report -m after running coverage run main.py any of the lines in the methods that I have test are covered, I using a context.py file and I have the following project ...
7
votes
3
answers
18k
views
Coverage-Gutter extension for visual studio code is not showing line coverage in python3 project
I installed coverage gutter extension for visual studio code but is not showing the line coverage, when I press Coverage Gutter display coverage or press the "watch" option in the footer it says "...
17
votes
3
answers
5k
views
Tox 0% coverage
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 ...
7
votes
1
answer
2k
views
Implementing code coverage and unit testing on existing Python/Flask app
Having trouble getting this implementation down.
What I need: Code coverage results on my existing flask application, preferably using unit tests compatible with pytest.
What I am seeing:
I am ...
3
votes
2
answers
3k
views
How can I improve code coverage of Python3
With unittest and Coverage.py,
def add_one(num: int):
num = num + 1
return num
from unittest import TestCase
from add_one import add_one
class TestAddOne(TestCase):
def test_add_one(...
2
votes
2
answers
2k
views
Using pytest coverage and codecov.io with Python
When I run pytest --cov I get a coverage value of ~60%. The report generated on codecov.io after the code is pushed to github shows 100%. I cannot understand how the two are different, I thought the ...
2
votes
3
answers
2k
views
Why are most of my project's Django files missing from the PyTest Coverage report?
I'm running pytest-cov and pytest-django using tox. I have a very simple tox.ini file with limited omit files. The problem is when I run pytest using tox -e unit, I get a limited Coverage report:
----...
1
vote
1
answer
267
views
Exclude venv from HTML coverage export in PyCharm
After running all my tests with coverage on PyCharm, I need to export coverage report as html. When I do this, the entire venv folder is included even though it is marked to be excluded in the project ...
7
votes
1
answer
4k
views
python test coverage comparison with previous run
I am using coverage.py to check the code coverage of my unit tests, in form of html report.
coverage run -m pytest
coverage html
The report is pretty cool which shows the overall coverage % and the ...
4
votes
1
answer
5k
views
How to measure coverage in a proper way
Pytest + coverage are showing very strange coverage statistics.
They are counting only those modules where tests were added, but other Python modules are not calculated for some reason.
I have a ...
2
votes
0
answers
709
views
How do I get coverage to recognize an exit error?
My goal is to reach 100% coverage on unit tests I'm writing (Python 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32)
The code I'm testing has exit ...
0
votes
1
answer
2k
views
python coverage error during html report (NoSource: No source for code:)
I encounter the following error during reporting html coverage.
myrepo>coverage report html
html NoSource: No source for code: 'C:\Users\usr\AppData\Local\Programs\Python\Python37-32\Lib\html': [...
18
votes
3
answers
13k
views
PyCharm: Coverage in community edition?
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?
1
vote
1
answer
2k
views
Jenkins : Coverage.py warning: No data was collected
Here's my .coveragerc
include = */<project-dir>/*
My sample script:
echo "Running unit tests along with coverage"
coverage run -m pytest
echo "printing coverage report"
ls -al
echo "getting ...
2
votes
2
answers
5k
views
Coverage appears to load coveragerc file, but all configuration remains default
I may be missing something obvious here, but I don't seem to be able to get coverage to load configuration data from a .coveragerc file when being used as an imported module, although it does seem to ...
3
votes
2
answers
3k
views
coverage.py gives "No source for code", despite .coveragerc seemingly telling it where the code is
If I invoke python3 -m coverage run ... inside a docker container, I get a .coverage file as desired.
However, if I try to generate the html or text reports using that .coverage file outside of the ...
5
votes
3
answers
6k
views
Python test coverage for class' __str__
I have a very basic questing regarding Python coverage tests using PyCharm IDE. In my Django models, all the __str__ methods are not covered in my tests.
class Category(models.Model):
name = ...
2
votes
0
answers
693
views
Running Python coverage collection around a process that forks
I have a Python application I'm running within a Docker container. That application is normally started with the command /usr/local/bin/foo_service, which is a Python entry point (so it's just a ...
4
votes
2
answers
1k
views
Python Coverage - Analyze only project files
I'm using coverage module in python to check the code coverage. However, while running 'coverage report', the module is analyzing unwanted files shown below other than the project files.
How can I ...
2
votes
1
answer
683
views
Coveralls: Error- No source for in my application using Docker container
I've been trying to integrate code-coverage in my Django application.. The build is successfull and all the tests are successfull but when i check coveralls.io or codecov.io there is no data.. I have ...
1
vote
0
answers
516
views
How to get code coverage results of multiple files through a python script
I am having troubles using the coverage.py module in my python script. The scenario is:
I have a script which calls upon test scripts and executes them as this was the only way to call multiple tests ...
0
votes
2
answers
1k
views
How can I run a thrift server or TCP server as a pytest fixture?
platform linux2, python 2.7.12-final-0
My integration tests ping an external server but I would like to change that to use a test fixture.
I have been trying a few days to run a Thrift library TCP ...
7
votes
1
answer
8k
views
How to configure Python coverage.pl report for Gitlab
I'm new to Gitlab, trying to setup coverage report -m for Gitlab. When I run manually, coverage report -m gives me the report. Just cant figure out what needs to be done to get that display on Gitlab.
...
4
votes
1
answer
2k
views
Run coverage on tests directory via Travis-CI
I am unable to run coverage.py in the tests directory from a Python project. I have a tests directory containing an __init__.py file and some test_*.py files where I define the tests I want to run in ...
23
votes
5
answers
16k
views
Coverage badge in Gitlab CI with Python coverage always unknown
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 ...
2
votes
1
answer
4k
views
Python coverage not finding my own modules
My code executes correctly using python3, but using coverage3 returns an ImportError when importing a package I created.
My project looks as follows:
components/common/ConfigTest/ConfigTest.py -> ...
1
vote
0
answers
8k
views
Coverage "Pragma: No Cover" does not work for modules in sub folder
I am trying to add "Pragma: No Cover" to modules that do not require coverage. But coverage.py is only recognizing the comment in modules in the root folder. It does not work on modules that are ...
0
votes
1
answer
163
views
Django/Python: how to know which tests cover a piece of code?
I know coverage python package is capable of creating reports (in html) that show if pieces of code are covered by tests, or not. I can also run just a single individual test, and know what does it ...
1
vote
0
answers
303
views
Coverage.py does not include all files and folder specified
Line below is the part of my manage.py code
cov = coverage.Coverage(branch=True,
include="app/*"
But when i run test with coverage i received coverage for only two files ...
1
vote
1
answer
710
views
Disable coverage while running nosetests
I'm new to Python. I am new to PyCharm.
I am trying to debug through my unit tests. They are done with nosetest.
Currently, when I run my tests with the vagrant debugger, it gives me the following ...
1
vote
1
answer
522
views
Ignore deprecated methods with python coverage testing
I am doing some coverage analyis on a code base that contains a fair amount of deprecated (using the deprecated package) methods.
Most of these deprecated methods do not have any tests. So when doing ...
4
votes
3
answers
15k
views
Test if __name__ == "__main__": with click and pytest
I have the following code in test.py:
import click
@click.command()
@click.option('--text', default='hello world', help='Text to display.')
def say(text):
print(text)
if __name__ == "__main__":
...
5
votes
0
answers
724
views
coverage badge is stuck on "unknown"
I am trying to use coveralls.io to show a coverage badge for my tests, but the coverage badge is stuck on "unknown".
The relevant repo is here: https://github.com/Noah-Lc/simple-blog-rest-api
When I ...
5
votes
1
answer
8k
views
Run coverage test in a docker container
I am trying to use the coverage tool to measure the code coverage of my Django app, when i test it work fine, but when i pushed to github, i got some errors in travis-ci:
Traceback (most recent call ...
0
votes
1
answer
29
views
Collating code files in multiple locations
I'm trying to use coverage.py on my unittest-based tests.
I see that there are multiple kinds of paths and they're not collated, so the coverage data is wrong.
/home/travis/virtualenv/python3.6.3/lib/...
4
votes
0
answers
459
views
How to instruct coverage.py to omit top-level definitions and count only method's bodies?
I want to test the coverage of a single package within a large body of software (specifically an Odoo addon). I have no control over the overall setup of the test. Hacking Odoo to start the coverage ...
1
vote
1
answer
624
views
Merge html coverage reports from two different frameworks generated from coverage.py
I have two different automation framework in python for my test cases
Framework-1-is old and is going to be deprecated
Framework-2-is New one with enhanced capabilities
for time being i wanted to ...
0
votes
1
answer
157
views
How to prevent coverage.py in Django from resetting coverage between runs?
Searched the docs, but couldnt find a way to do this. I've been running my test suite with the following command:
coverage manage.py run test tests
This will run all tests in the 'tests' folder. ...
1
vote
1
answer
3k
views
.coveragerc unable to locate files I want omitted
I am using tox to automatically run my tests using pytest and pytest-cov plugin. However, I'm getting coverage reports for the files I omitted in .coveragerc:
(env) alex@smartalex-pc:~/.repos/codelib/...
4
votes
1
answer
3k
views
Coverage: pragma: no branch with multiline statement
For the python coverage package, a missing else can be ignored for the resulting coverage by using # pragma: no branch.
It seems, that this is not working when breaking a long if statement in ...