546 questions
0
votes
0
answers
171
views
How to get coverage for multiple test files with coverge.py [duplicate]
Sorry if the questions already been asked, but when using coverage.py to get Code Coverage reports, how do I get the coverage throughout mutliple test files? For example, if I had a directory ...
0
votes
2
answers
926
views
coverage.py not reporting error from run command
I have a bash script that runs my tests:
#!/bin/bash
coverage run --source='directory_for_coverage' manage.py test
coverage report --fail-under=87
but when I run the script it only returns an error ...
0
votes
0
answers
196
views
Python Unit test for method contains request
I have a method, which contains external rest-api calls.
ex:
def get_dataset():
url=requests.get("http://api:5001/get_trainingdata")
filename=url.text[0]
return filename
When I ...
0
votes
1
answer
2k
views
Coverage - PermissionError: [Errno 1] Operation not permitted
I using pytest and coverage modules for test cases and code coverage.
From the project root, I'm able to execute pytest -v but not pytest -v --cov=./ (stack trace below)
I set PYTHONPATH to the ...
0
votes
0
answers
891
views
Specifying Location of Code Coverage Data FIle
I'm trying to integrate code coverage with Travis CI for a python repository.
In the project root, my .coveragerc looks like:
[run]
data_file = tests/coverage/.coverage
omit = data-structures/lib/*
[...
0
votes
1
answer
713
views
How can I raise an error from a coverage test on azure devops pipeline?
My test code has some fails.
But the pipeline ignores the error and runs successfully.
How can I raise an error?
azure-pipelines.yml
...
- script: |
pipenv run coverage run --rcfile=...
0
votes
0
answers
978
views
How to use coverage.py to display line numbers of function defintions?
I want to measure the functional coverage of python programs. Reporting the line numbers of the function def lines. Can this be done using Ned Batchelder's Coverage.py? There's branch coverage which ...
0
votes
1
answer
2k
views
Jenkins Build not failing though coverage is below 80%
Trying to fail Jenkins build even if one of the python test files has less than 80% coverage.
Towards it, in Jenkins I'm using nosetests to run test coverage on 2 python test files. It prints results ...
0
votes
0
answers
643
views
Should coverage.py present unit test code's coverage too?
I have a small Python 3 project that I intend to keep as a reusable library. Let's call it utils_common. The coverage report from coverage.py includes some coverage for actual unit tests code along "...
0
votes
1
answer
677
views
How to attach a html file within project directory and send it as mail?
I am trying to send the coverage report generated after execution of test cases, which is generated in htmlcov folder,
import os
from django.conf import settings
from utils import email_utils
def ...
0
votes
1
answer
79
views
Collection python coverage with a tcsh wrapper
I have a python script that being run by a wrapper that is written in tcsh. I'm trying to use the Python Coverage.py module in order to collect coverage of the python script. I tried:
coverage run ...
0
votes
1
answer
386
views
Python coverage is installing without C extension on Windows under python 3.8, but not under python 3.7, how do I force the C extension version?
I have python 3.7.5 and Python 3.8 installed on the same windows 10 machine. They were both installed from python.org/downloads. When I run pip install coverage (using the latest release of pip) it ...
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 ...
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)
...
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/...
0
votes
1
answer
332
views
Is there a standard way to store test coverage results to compare them in time?
I have a Django project in which I can run coverage and create the report
coverage run --source='.' manage.py test my_app
I would like to compare the results over time after code refactors. Is there ...
0
votes
1
answer
36
views
How python brings functions into scope?
I contribute to scikit-image and was using coverage. Now, when I did
coverage run benchmarks/benchmark_name.py
and then generated the report, there were a lot of files that didn't have any link to ...
0
votes
1
answer
2k
views
how to use coverage run --source = {dir_name}
I have certain files in a directory named benchmarks and I want to get code coverage by running these source files.
I have tried using source flag in the following ways but it doesn't work.
coverage3 ...
0
votes
1
answer
659
views
nose.plugins.cover: ERROR: Coverage not available: unable to import coverage module
When trying to compute coverage for a python project, I run into the following error:
nose.plugins.xcover: ERROR: Coverage not available: unable to import coverage module
This is the command I'm ...
0
votes
1
answer
351
views
PyDev where to put .coveragerc
I want to exclude some abstract methods from code coverage and followed the suggestion of using an exception and a .coveragerc file as described here
This method works fine, if I run coverage from ...
0
votes
1
answer
565
views
django coverage fails to include most py files
I have run coverage on a project that I set up with cookie cutter for django. In the report, coverage includes the py files in the user app that cookie cutter set up for me, and includes my html ...
0
votes
0
answers
238
views
Can other extensions (besides .py .pyc .pyo) be recognized as Python modules?
I have a few test files residing in test/ directory which has an __init__.py file. The test files are basically Python files but have the extension as .thpy (Python test files). Each of these tests ...
0
votes
1
answer
217
views
Coverage works on Windows, but fails on Linux machines
I'm currently writing unit tests for Python, for this I'm using a combination of the built-in 'unittest' module and an external library called 'coverage'.
When generating a report on windows, I get ...
0
votes
1
answer
61
views
Using coverage to test python program
I'm using https://coverage.readthedocs.io/en/coverage-4.4.1/ to determine how much of a Python program I'm using.
However, when I use command line:
$coverage myprogram.py
It runs the program in ...
0
votes
1
answer
91
views
Coverage with nosetests not exiting
I have an instance of Atlassian Bamboo running that calls and creates a code coverage website using the coverage.py script.
it calls:
coverage run $(which nosetests) --with-xunit $test_files
...
0
votes
0
answers
664
views
How to erase coverage data before run test case?
I use coverage API in WSGI project. When I not run test case,the coverage report reach 30%. So, I want to erase coverage data before run test case and also after start up WSGI project.
I set a socket ...
0
votes
0
answers
405
views
How can I acquire python test coverage matrix
I want to make a matrix that looks like the following
Currently I'm trying to acquire the above matrix for Django test cases. However, coverage.py(the coverage tool that I'm using) doesn't seem to ...
0
votes
1
answer
563
views
Coverage failing on Travis but not on local machine - error depends on order of flags
I'm have the following script section in my .travis.yml file:
script:
# run all tests in mymodule/tests and check coverage of the mymodule dir
# don't report on coverage of files in the mymodule/...
0
votes
1
answer
613
views
Django functions definition in views.py not shown in coverage?
I am using coverage in the following way to test my django app:
DJANGO_SETTINGS_MODULE=$(SETTINGS) coverage run manage.py test -v 2
DJANGO_SETTINGS_MODULE=$(SETTINGS) coverage report
In my test ...
0
votes
0
answers
24
views
In coverage.py, how do I test an import exception [duplicate]
In my code I have:
try:
import json
except ImportError:
import simplejson as json
Coverage says that the ImportError isn' tested. How do I go about writing a proper unittest to ...
0
votes
0
answers
86
views
Django coverage report builder .xls export test
Im using coverage to test a view that exports a xls file using report builder code.
This is the view code :
from report_builder.models import Report
from report_utils.mixins import DataExportMixin, ...
0
votes
1
answer
1k
views
coverage.py and functional testing
I'm attempting to use coverage.py to measure code coverage when running functional tests against a Flask server instance. It failed to detect the execution of several functions in a file that I know ...
0
votes
1
answer
437
views
coverage.py can't collect any data for coveralls failing in travis
I am building a python application in travis. I have setup.py which basically runs the command:
py.test packageName
when we do: setup.py test
I am trying to run coverage plugin to push to ...
0
votes
0
answers
199
views
PyDev Branch Coverage
Is there any way to configure PyDev's coverage.py integration to spit out a report with branch coverage?
I see in the resulting command line in the run configuration, that Eclipse/plugins/org.python....
0
votes
1
answer
374
views
Module coverage not available in coveralls test
I'm trying to implement a test code coverage and I'm having problems with coveralls. For doing this i'm following this guide:
https://github.com/coagulant/coveralls-python
My problem is that when ...
0
votes
1
answer
633
views
Django reusable app testing - coveragerc
I'm developing a Django reusable app. My development setup looks like this:
~/development/django-foo/
foo/
apps.py
fixtures/
...
forms/
...
...
0
votes
0
answers
169
views
Python/Django Code Coverage doesn't cover classmethods
I'm using coverage.py to check the test/code coverage and it seems to consistently skip over any class methods. Is there a way to fix this?
0
votes
2
answers
954
views
Django 1.6 coverage data showing virtualenv items
I have a django 1.6 project which have minimal test coverage
when I run
bash
coverage run manage.py test mainapp
coverage report --include=mainapp/*
the output is
Name Stmts Miss ...
0
votes
1
answer
134
views
coverage of django application deployed on production server
Can anyone please tell how to find the coverage of django application deployed in apache.I want to hook in coverage.py in the deployed django application.
0
votes
1
answer
132
views
Why doesn't "coverage.py run -a" always increase my code coverage percent?
I have a GUI application that I am trying to determine what is being used and what isn't. I have a number of test suites that have to be run manually to test the user interface portions. Sometimes I ...
-1
votes
1
answer
680
views
what does {} and format do in this command python? [duplicate]
Hi i am reading a source and it has a line:
fn = 'total-listmix-{}-{}.xml'.format(opt.os, opt.compiler)
exept Exception as e:
raise Exception('error merging coverage: {}'.format(e))
I think the {}...
-1
votes
1
answer
157
views
How can I use coverage to detect if a code execution would cover additional lines?
I recently became the maintainer of PyPDF2, a library for reading / writing PDF files. In order to get more confident/quick with merging PRs, I introduced quite a lot of tests.
I use pytest and ...
-2
votes
1
answer
142
views
interpretion of branch coverage
This is kind of an followup question to How do I interpret Python coverage.py branch coverage results?
I have a different situation where I check a variable perr which has in different scenarios, ...
-2
votes
1
answer
621
views
Python module not found with sudo in github action
I wanted to use coveragepy combine to seperate .coverage files into one.
For that I installed python and the coverage module via pip, afterwards then running this command. python -m coverage combine ....
-3
votes
1
answer
238
views
How to combine coverage.xml files for github action coverage report? [duplicate]
I wrote code related to a website in python. Below is my file structure,
├── app_layer
│ ├── src
│ └── tests
├── core
│ ├── src
│ └── tests
├── model
│ ├── src
│ └── tests
├── .github
│ ├...