546 questions
0
votes
1
answer
229
views
no-data-collected when running tests with tox but not when running tests with pytest
I'm using tox to run unit tests with pytest. When I run the tests with tox, it runs the tests and shows the tree of my src directory but prints CoverageWarning: No data was collected. (no-data-...
0
votes
0
answers
113
views
Error while running coverage run because of os.environ in python
My code is importing several variables using os.environ. When I run 'coverage run' command for testing, it gives key error. Is there a way to provide env files to read env variables from there, or ...
0
votes
1
answer
106
views
How to log coverage report to logs or summary?
I have a workflow that looks like this:
on:
push:
branches:
- master
jobs:
git_pull:
runs-on: self-hosted
steps:
- name: executing remote ssh commands
uses: appleboy/...
0
votes
0
answers
35
views
Why 'coverage' considers all of my class-based-views as tested?
I'm just learning django testing.
When I use 'Coverage' module to check which parts of my code is tested, it considers almost all of class-based-views as tested while I have commented out all of my ...
0
votes
1
answer
57
views
"... && coverage report" not working after switching to pytest-django
I was using unittest in Django to write tests and running the tests with this command:
coverage run --omit='src/manage.py,src/config/*,*/.venv/*,*/*__init__.py,*/tests.py,*/admin.py' src/manage.py ...
0
votes
1
answer
303
views
Coverage's dynamic context usage returns 'no contexts were measured'
I'm interested in seeing what test triggers what code via the coverage tool.
I followed the instruction https://coverage.readthedocs.io/en/latest/contexts.html#dynamic-contexts, to enable dynamic ...
0
votes
1
answer
964
views
Pytest reports missing lines in coverage for imports and constant assignments
I'm baffled by differences in coverage behavior for different files in my project and hope someone will please suggest how to debug this more effectively than I am doing now. This is basically the ...
0
votes
1
answer
95
views
How to get coverage for lines following call to a Cython module
I have some code which uses a library that happens to use Cython under the hood.
I'm observing that, following any call to a Cython function in that library, no lines in my own code are picked up as ...
0
votes
1
answer
449
views
Run Tests with Coverage "TypeError: Parameters to Generic[...] must all be type variables"
When running tests with coverage using PyCharm on django (python) project, im having the following error:
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm 2023.1.2\...
0
votes
0
answers
307
views
coverage/pytest and gitlab CI not running
I am currently having two issues involving coverage/pytest and gitlab CI.
The bigger and more recent one is that pytest and coverage do nothing at all when i call them in the gitlab CI. I do not get ...
0
votes
1
answer
52
views
How to write coverage test case for wxpython's event.Skip()?
I am trying to increase my coverage percentage on my coverage report and there is this method that I want to write a test case for using an **assert ** statement. It is only one line, but for my test ...
0
votes
0
answers
424
views
Python coverage test percentage higher than expected
Python 3.10
I'm working on my first Python project and am confused by the following output when I run
coverage run -m pytest followed by venv/bin/coverage report --show-missing. I'm specifically ...
0
votes
1
answer
1k
views
How can I achieve test coverage for `ClientError` exceptions raised in my unit tests for a Python script that utilizes boto3 and moto?
I have this python script snippet with mocked aws infrastructure for a todo list application:
import os
import boto3
import time
import uuid
import json
import functools
from botocore.exceptions ...
0
votes
0
answers
147
views
Why my unit test coverage is at the lower side?
I have written a small class and function and unit test case for them.
from flask_restful import Resource
class Calculator:
def __init__(self, a, b ):
self.a = a
self.b = b
...
0
votes
3
answers
639
views
Django was unable to create a connection to the 'postgres' database and will use the first PostgreSQL database instead -Coverage
I am trying to run python tests using coverage. However, when I try to run the command, the following error appears:
$ python3 manage.py test
Creating test database for alias 'default'...
/workspace/....
0
votes
2
answers
356
views
Python coverage saving files outside of docker but not inside
So I've been wanting to integrate code coverage in my tests and for that im using the coverage api.
I have a exit handler which gets triggered on SIGINT, SIGTERM and SIGABRT signals:
import logging
...
0
votes
1
answer
182
views
Disabling tf.function decorators for code coverage pytest run
As discussed here, code coverage tools do not work nicely with tensorflow due to its code transformation. One suggested workaround is to use tf.config.experimental_run_functions_eagerly(True) when ...
0
votes
0
answers
283
views
Function import issue running pytest on Gitlab CI
I have a script 'interceptor.py' with a function
def isIPValid(string):
and a unit test script for pytest 'test_interceptor.py' with a test for this function:
import interceptor
def test_isIPValid():...
0
votes
0
answers
80
views
How can I test an Exception inside an async with?
in my tests I did a coverage and I end up with untested parts inside an async with, what the coverage sees is the part about exceptions, my code is like this:
@classmethod
async def ...
0
votes
0
answers
144
views
Python coverage for gstreamer threads
I'm trying to run python coverage on an application that uses the gstreamer python bindings to create a pipeline and I'm not able to get it to report (or collect) coverage for the user defined ...
0
votes
1
answer
972
views
Error loading conftest.py due to missing field "lineno" from alias
I have a python/flask application with a test suite.
When I run
coverage run -m pytest -s tests
I get the following error:
ImportError while loading conftest '/Users/abc/Documents/server/app/tests/...
0
votes
1
answer
150
views
ModuleNotFoundError on own made model folder
Doing some testing on my own game that I am using to learn python. I am attempting some Code Coverage using the CoveragePY that I have installed via PyCharm's Package Manager. Wrote up my tests, right ...
0
votes
1
answer
741
views
Python coverage used in Django takes too long to execute even though it is run with --source flag option
I am using the Python package in combination with the Django testing framework and sometimes want to test only one app/directory/package stated in the coverage --source option.
coverage run --source='...
0
votes
0
answers
40
views
Pytest coverage not detect attribut class check
Below my class I want to check
class Toto:
me = 0
def good(self):
return "OK"
With my test launch with pytest and pytest-cov plugin
def test_attr_class():
assert Toto.me ...
0
votes
0
answers
140
views
Coverage.py report split between a lot of HTML files
I am using coverage.py library for generating the code coverage report. But the issue is my coverage report is being split into different html files and they are not included in the **index.html** ...
0
votes
1
answer
818
views
Cover only directly called code from test function in pytest coverage
I need to cover only code that is called directly from test function, every nested method call must be marked as missed. This must help me ensure that every unit/method has his own test.
Example: test ...
0
votes
1
answer
222
views
Trying to have separate fail_under values for different modules in monorepo using coverage.py
The problem is basically summed up by the title but simply put, I am implementing coverage requirements for a mono-repo codebase that is maintained by multiple teams.
Contraints:
All of our utilities ...
0
votes
0
answers
834
views
Code Coverage in python without unit tests
I have a python (Django) application for which I want to generate a code coverage report, but the solutions I have found on the internet mostly work with test runners or requires unit tests for ...
0
votes
1
answer
233
views
coverage report post step not picking up data in previous step
I have a post always step in Jenkinsfile that runs coverage report -m. The reason why it's in the post step is I want coverage report, regardless even if tests fail. I see that it's running but it's ...
0
votes
0
answers
422
views
pytest + coverage for blanket try-except blocks
To learn about packaging, I've written a small script that converts a text string to Morse code.
I have a function that opens a JSON file and returns the contents as a dictionary. This function passes ...
0
votes
0
answers
1k
views
Tox failing when run inside Github Actions because pytest uses incorrect python version to run tests
I have a basic Python project (Full repository HERE) with a tox.ini file which runs on 3.10. When run locally, all tests pass and coverage is at 100%
When run on Github actions, the coverage is only ...
0
votes
1
answer
749
views
coverage.py's SQLite use seems to break my test suite, which also uses SQLite
I'm porting some code from python2 to python3. Part of that is seeing how much our Flask-based REST API is covered by our automated tests, and deciding where, if anywhere, manual testing is needed.
...
0
votes
0
answers
295
views
How to get missing branches information in coverage.py html report
Currently I am using coverage.py to get coverage report of python code. I am using --branch flag to get branch coverage in the report. In the html report header I am getting these attributes
Module ...
0
votes
1
answer
266
views
How do I access the coverage database generated by coverage.py and get a list of all executed statements?
The coverage report only shows the percentage, and I would like to know all executed statements.
Eventually, I need a map in which the key is the statement and the value is True(Executed)/False(Not ...
0
votes
0
answers
46
views
Django Unit Testing for standalone variables (coverage)
I'm starting to write unit tests for a django project, and running coverage shows I have 0% coverage over a simple list of tuples.
Example:
STATE_CHOICES = [
("MO", "Missouri",)...
0
votes
2
answers
131
views
In coverage.py, how to get minimum file coverage?
I am running coverage with this line, where $FILES is list of modified file in the current pull request.
coverage run --include=$FILES -m pytest tests -vv -rf -x
This works fine, however this is the ...
0
votes
0
answers
747
views
How to run pytest file by file in no particular order
I am testing a backend of Flask and MongoDB but run into a problem when running the total test suite. If I run certain files in the test suite independently, they work fine. I wrote a script which ...
0
votes
0
answers
344
views
Do we need to clean up nosetest .coverage files?
It seems to me that we need to clean up the .coverage hidden files created by nosetest or else nosetest would be confused when I try to run it a second time. It may return cached results in the ....
0
votes
0
answers
490
views
Use of code coverage tool 'coverage.py' to test code coverage having multiple child subprocess shell command calls
I'm using coverage.py tool https://coverage.readthedocs.io/en/stable/index.html to see code coverage of tests around a python project.
I have 8 tests which may cover different files of the project , ...
0
votes
0
answers
472
views
How to exit the coverage run process if one of the tests is taking more than x sec in Python?
I am using coverage in python to run unit tests.
I am using the below command for this ->
coverage run --source . -m pytest --junitxml=unit_test_results.xml --disable-pytest-warnings --ignore=<...
0
votes
0
answers
95
views
python coverage no source for code (builtin)
What I did is:
coverage run --source=HelloCNN1 test_hellocnn1.py
coverage run --source=HelloCNN2 test_hellocnn2.py
coverage combine
coverage report -m --skip-empty
The error output:
(base) zz@home% ...
0
votes
0
answers
776
views
Type checking Python with MyPy breaks test coverage reports
I have been adding type checking with MyPy to various python projects and I've found that doing so prevents Coverage from properly generating test coverage reports. Specifically it prevents coverage ...
0
votes
1
answer
216
views
pytest-cov functionality for package specific coverage thresholds
I am using pytest-cov for coverage checks on my repo. Is there a functionality by which I can specify coverage thresholds for a specific package/packages within a repository? Currently my coverage ...
0
votes
1
answer
448
views
Calculate test coverage percentage only using coverage.py to create gitlab badge using anybadge
Gitlab only provides to visualize the coverage.py report for the default branch using a hard-coded logic: https://docs.gitlab.com/ee/ci/pipelines/settings.html#test-coverage-report-badge
As I want to ...
0
votes
1
answer
1k
views
Issues between include and source with coverage.py
I have a project that is setup with the following minimal structure:
workspace/
|- .venv/ # virtual environment
|- .vscode/ # ide settings
|- my.repo.folder/ # git repo. Note: these have periods ...
0
votes
1
answer
135
views
Python sub-process coverage on Travis
I've seen a couple of articles on the subject, but none seem to work for me.
The case
A Python package with tests based on unittest, pytest as test runner and plugins like pytest-cov to support the ...
0
votes
0
answers
265
views
Why does nose ignore certain files on coverage report?
I am running tests on a project I've been assigned to. Everything is triggered by calling tox.
Default tests run with nose, which adds a coverage report, this is the command that tox calls:
django-...
0
votes
1
answer
270
views
Select suite of tests for coverage with pytest
I'm running a set of tests with pytest and want also to measure its coverage with the coverage package.
I have some decorators in my code, dividing the tests in several suites using something like:
@...
0
votes
0
answers
143
views
Coverage module is not picking installed modules at run(third party modules installed via wheel files)
I have installed a third party wheel file and I implemented/used one of the classes & exceptions(from wheel) into my piece of code. I wrote some unit-test cases for my piece of code. I am able to ...
0
votes
0
answers
393
views
Test case Code coverage using Coverage.py and Pytest
I'm trying to get the executed code out of each Pytest Test case -in order to make a debuger-, now it's possible in Coverage module apis i will use the following code:
cov.start()
assert nrm.mySqrt(x)...