546 questions
2
votes
1
answer
518
views
Why is coverage not 100% in this python-inquirer script?
I have a simple method that receives a list of trades (descriptions and ids) and return the id of selected ones. If none is selected, you are asked to confirm that. I used python-inquirer to do that:
...
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 ...
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 ...
2
votes
0
answers
694
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 ...
2
votes
1
answer
1k
views
How to run a coverage report only on the functions changed in a PR?
I am working on an enormous django project that takes hours to generate a coverage report (using the coverage.py library). Instead, I want travis to generate a report on only the functions that have ...
2
votes
2
answers
506
views
Using pytest, is it possible for a unit test to know that it is being run with code coverage monitoring on?
I am currently developing some tests using python py.test / unittest that, via subprocess, invoke another python application (so that I can exercise the command line options, and confirm that the tool ...
2
votes
0
answers
629
views
How to use nosetest to find coverage of non-tested Python files?
The nosetests tool for Python testing has an option --cover-inclusive to include all files to be able to discover holes in testing (see documentation). However, it does not seem to work properly: it ...
2
votes
2
answers
119
views
Given an object, how to get a list of bound methods which are called during runtime
The question comes from this scenario:
We've built a framework to test northbound apis of our project, based on pytest.
And now we want to have a coverage report about how many apis are tested(...
2
votes
0
answers
177
views
Pycharm - coverage in mako templates
I've got tests to cover 100% of my Python code. Beside it my code fails on TypeError in mako template.
Is it any way to make pycharm's coverage show code coverage in templates too?
2
votes
0
answers
1k
views
Nosetests with coverage - cover only project's files
In my project I have the following structure of files:
..
file1.py
file2.py
tests/
test1.py
test2.py
I have installed nosetests and coverage and I run tests with the following command (...
2
votes
0
answers
252
views
Generating package name attribute with nose coverage reports
I'm configuring reports in Jenkins and
nosetests --with-xcoverage
gives me XML with an empty name attribute:
<packages>
<package branch-rate="0" complexity="0" line-rate="0.282" name=""&...
2
votes
1
answer
971
views
pdb still will not show output even after using -s option with Django Nose
I'm trying to debug my tests and I am using a custom testrunner. I am able to get pdb to function just fine when I am not using it in conjunction with manage.py.
in mysite/blog/tests/models_tests.py ...
1
vote
1
answer
2k
views
pytest-cov plugin reports imports and function definitions not being covered by tests
I am using pytest coverage and following I have the tests scripts in the command line that will generate the coverage reports for me:
"""Manager script to run the commands on the Flask ...
1
vote
2
answers
2k
views
coverage report showing zero
this code is saved with calc.py. This is a basic calculator program in which I have used flask module.
def sum(number1,number2):
result= number1+number2
return result
def sub(number1,number2):...
1
vote
1
answer
3k
views
How to send pytest coverage report via email?
I am using pytest framework and pytest-cov plugin to get the coverage report generated, which generates a coverage report file inside htmlcov directory after the test cases are executed, is there a ...
1
vote
3
answers
4k
views
With coverage.py, how to skip coverage of import and def statements
I have a python program that imports other files which potentially import other files, as is normal with python development
The problem is, when I measure coverage with coverage.py, some files which ...
1
vote
1
answer
1k
views
Number of unit test using nosetests is not reflecting in sonar report for python codebase
I am trying to get test coverage report and unit test details (number of test cases, # of passed test cases) into sonar.
I have generated report using coverage and nosetests plugin and stored same ...
1
vote
1
answer
1k
views
Coverage test for create view class and update view class
I'm writing coverage test cases for my app views. I have used Createview and Updateview classes with modelform and also used get_success_url() for response redirect.
When I passed data for the form ...
1
vote
2
answers
565
views
Django-jenkins --enable-coverage returns 'Coverage' object has no attribute 'data'
I am using django-jenkins v0.110.0 and coverage v5.2.1 , with Django v3.1.
As mentioned in the subject, when I ran:
python manage.py jenkins --enable-coverage
I get this error:
AttributeError: '...
1
vote
2
answers
365
views
How to instruct a magic mock on how it should treat its arguments
I've run into the following (edge?) case that I don't know how to handle properly. The general problem is that
I have a function that I want to test
in that function I call an external function with a ...
1
vote
1
answer
1k
views
Code Coverage not working with PyDev
First, sorry for asking again. I found some posts on this topic, but none of the recommendations worked for me. The outcome is well known: PyDev always reports "File has no statistics".
In a previous ...
1
vote
1
answer
911
views
Exclude files from coverage report
I'm trying to exclude some files from a coverage report. I'm using TravisCI and Coveralls.io for test my project.
My test code is as follows:
script:
- cd ../
- nosetests --with-coverage --cover-...
1
vote
1
answer
27
views
Exclude directory but include file in coverage.py reports?
I want to exclude tests directories, but include one file from the tests directory. Example .coveragerc:
[run]
omit =
*/tests/*
!*/myapp/tests/my_file.py
but I think coverage.py doesn't ...
1
vote
1
answer
567
views
Pytest cov doesn't recognize option
I'm running pytest with pytest-cov with the following command line:
python -m pytest Mytools\tests --junitxml test_reports\unittest_result.xml --cov . --cov-branch --cov-report xml:test_reports\...
1
vote
1
answer
2k
views
pytest does not find .coveragerc configs
I am trying to run pytest with coverage output, using a .coveragerc file.
First of all, here is my folder structure:
playground/
├─ excercise.01/
│ ├─ calculator.py
│ ├─ test_calculator.py
├─ ....
1
vote
1
answer
1k
views
Python 3.7 pytest coverage marks 'if' blocks without 'else' statements as uncovered
When I run test, code in the "if" block is called and executed. However pytest-coverage marks it as missing(coverage decreases).
It's uncovered if I write like this
if some_working_condition:...
1
vote
1
answer
232
views
How to apply pagespeed insights results
Well, I trying establish a web page with a wordpress and GoDaddy hosting. I want to make fast web page, because people says fast web pages appear on first line at Google (as specially mobile web page ...
1
vote
2
answers
2k
views
code coverage of a file using coverage.py using a python script
I want to get the code coverage of a python file say "Test.py". Now, when I write the script for this using coverage.py, it looks like this,
import coverage
cov = coverage.Coverage()
cov.start()
#...
1
vote
2
answers
3k
views
How to find code which was never executed in coverage.py despite a 100% coverage report
Consider the following code:
import math
def dumb_sqrt(x):
result = math.sqrt(x) if x >= 0 else math.sqrt(-x)*j
return result
def test_dumb_sqrt():
assert dumb_sqrt(9.) == 3.
The test ...
1
vote
1
answer
523
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 ...
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/...
1
vote
1
answer
145
views
Why coverage is not showing error for generic views?
I am using coverage to check which unit tests to write. I'm checking in accounts/views.py, for which I haven't written any tests, but why it's not showing tests missing case(i.e in red)?
I expect ...
1
vote
1
answer
536
views
How do I run python code-coverage on multiple platforms
I am using coverage.py on my code (python 2.7), inside PyDEV on Windows.
I have bits of code that run only on UNIX, usually starting with:
if os.name == 'posix':
and I want to make sure this is ...
1
vote
2
answers
3k
views
Error in eclipse, when import coverage?
in mac terminal
$ coverage help
Coverage.py, version 3.5
Measure, collect, and report on code coverage in Python programs.
While in the eclipse, I encounter error as follows: please give a hand
...
1
vote
1
answer
1k
views
Python doesn't see submodules when running under coverage and nose
I get an import error when I use coverage.py to run a suite of tests where nose is the underlying test runner. The tests run fine if I just run under Python instead.
coverage run run_tests.py
ERROR
...
1
vote
1
answer
824
views
Why does coverage.py not report a for loop where the body is not skipped when running it with --branch?
Consider the following example file test.py:
def fun(l):
for i in l:
a = 1
print(a)
if __name__ == '__main__':
fun([1])
Testing branch coverage with
coverage erase; coverage run -...
1
vote
1
answer
1k
views
Databricks: run python coverage inside databricks jobs
I am using Azure Databricks, running a python script instead of using Notebooks.
Given the way Databricks is implemented, it's hard to test the code in my local machine, so I wanted to create another ...
1
vote
3
answers
2k
views
Creating tests to maintain minimum coverage?
Is there a way to create a Makefile/script that will fail if a file from coverage.py library has values below a certain threshold? Say 80%.
1
vote
1
answer
1k
views
Unit testing and coverage-ing a function using multiprocessing.Process() in python
I am trying to test a function that might crash, using multiprocessing.Process(). The code written below restarts the call if the function doesn't respond ideally within 10 minutes which is working ...
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/...
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 ...
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
1k
views
`coverage combine` results from different containers?
To reproduce:
Create a project with two services.
Test each service in its own container using docker-compose run --rm --entrypoint='pipenv run coverage run […]' [service-name].
Combine the results ...
1
vote
1
answer
271
views
nosetests coverage report skipping some .py files and not sure why
I'm running a nosetests command that results in strange results. See image: for details: folder structure and coverage results
Why aren't the files under the customercard_source/objects folder being ...
1
vote
1
answer
120
views
Configure tests and coverage to run at setup
I'm supposed to configure a python package with tests and coverage.
Now, I can successfully run tests (with nosetest) and coverage (through coverage.py), but I'm a little confused on how to make ...
1
vote
1
answer
367
views
Make each run of python interpreter automatically call `coverage`?
I have test.sh that runs python command on many different scripts. Is there a way to emit coverage -a for each python call without prepending each command with coverage -a?