546 questions
1
vote
0
answers
37
views
Why doesn't pytest-cov fail with a non-zero exit code when code coverage threshold isn't met, when running on multiple directories?
When the average test coverage threshold across multiple modules isn't met, pytest doesn't fail with a non-zero exit code, even though it should.
My command:
❯ pytest --cov module1 --cov module2 --cov ...
1
vote
0
answers
104
views
Exclude methods consisting of a single pass statement from coverage reports in python
In my class, I have some methods that can be overridden by subclasses, but do not need to be.
I like to test my project and generate a coverage report using coverage.py.
Because the method of the ...
0
votes
0
answers
43
views
How to run globally installed coverage on a package inside a virtual enviroment?
I'd like to run a coverage check with the following configuration:
coverage is installed globally on the system (via pipx).
pytest in installed inside the virtual environment of the project.
(Inside ...
0
votes
1
answer
289
views
The coverage run icon in the Test Explorer is not displayed in Visual Studio Code
The coverage run icon in the Test Explorer is not displayed in Visual Studio Code. Check snapshot. Is There a way to enable coverage on Visual Code interface?
I'm using Python pytest and working ...
0
votes
0
answers
72
views
diff-cover changes the ui of an azure devops?
So I was integrating the diff-cover tool in my repository and found that it sometimes gives in a UI format that the line was tested or not tested in the PR -> File.
Any idea how does this work?
...
1
vote
1
answer
111
views
coverage.py always reports one missing statement but the html report doesen't show what the missing statement is
I am using coverage.py to measure the statement/code coverage of my test.
There are two files that are being tested:
example_solution.py
created_unit_test.py
"example_solution" contains a ...
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
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
300
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 ...
22
votes
3
answers
7k
views
Azure PublishCodeCoverageResults@2 issue with detailed report for coverage
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 ...
2
votes
1
answer
337
views
Coverage of process spawned by pytest
I am trying to get coverage on a Python process spawned by pytest. Here are the steps I took:
Create a sitecustomize.py module in my local site packages directory
#/home/Olumide/.local/lib/python3....
0
votes
1
answer
889
views
How to display the right coverage for unit-tests in python?
I am having trouble displaying the correct coverage info for unittest. I created a simple python file as such: simple.py that contains the following contents:
def multiply(x, y):
return x * y
...
0
votes
1
answer
60
views
Cython coverage not showing properly
After any call to a Cython library, no lines show up as covered, even though I have tests that are clearly covering the library calls. I even tested this by putting in a obligatory ...
3
votes
0
answers
79
views
Test Coverage Does NOT Count lines coverred by Selenium Webdriver
This is a flask app with a rather simple pytest setup.
import subprocess
import time
import pytest
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
@pytest.fixture(...
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
1
answer
394
views
How do I find coverage for subprocesses under test?
Consider the following simple program:
# thingy.py
import sys
print("ready")
for line in sys.stdin:
print(line, end='')
If I want to unit-test the program, I can stub out the side-...
3
votes
1
answer
1k
views
Combine coverage reports into one xml in python
my python project is composed of several different packages
main_dir
|- package_1
|- package_2
|_ package_3
i'm testing each package separately with pytest and pytest-cov
python -m pytest package_1\...
6
votes
1
answer
2k
views
| python coverage report error | no source for code: PATH + '/_remote_module_non_scriptable.py'
When I run coverage run -m pytest tests/ followed by coverage report in the terminal
I get the following error:
No source for code: '/private/var/.../_remote_module_non_scriptable.py'.
It seems like a ...
3
votes
1
answer
1k
views
Coverage.py returns error "No source for code:..." when running tensorflow.keras.model.fit function
I have built unittests for my code and everything works fine when running them from vscode. Even running coverage run runs successfully.
But when I try to run coverage report I get the following ...
1
vote
1
answer
8k
views
Configure pyproject.toml for unittest and coverage
I used in the pass pytest but wanted to use this time unittest instead. I use the integrated testframework from vscode and for testing it just runs fine. Further I wanted to use coverage. My structure ...
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
...
-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 ....
2
votes
1
answer
1k
views
How to fix tox.ini when it keeps complaining about no module named coverage?
I am trying to send a Pull Request to an opensource library.
But I keep getting ModuleNotFoundError: No module named 'coverage'
This is the log in Github CI
Run tox -e lint,py310-dj40
lint: freeze> ...
5
votes
1
answer
7k
views
Test code and branch coverage simultanously with Pytest
I am using pytest to test my Python code.
To test for code coverage (C0 coverage) I run pytest --cov and I can specify my desired coverage in my pyproject.toml file like this:
[tool.coverage.report]
...
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
...