I am trying to setup tests with multiple version with .tox
I finally solved all the other strange issues that were coming up, however I am not sure why coverage won't report test coverage on anything inside the src directory. On my local machine, it works okay. But not on Docker.
I am using a debian-based image with a layer on top that installs tox and several python versions. I already managed to setup the project for another repo where it worked ok in the end, but not now.
Here's how it looks like on both local and docker:
On a docker container with tox
---------- coverage: platform linux, python 3.10.2-final-0 -----------
Name Stmts Miss Branch BrPart Cover
--------------------------------------------------------------------------------
setup.py 10 10 6 0 0%
src/bla.py 2 2 0 0 0%
src/core_file.py 701 701 243 0 0%
src/resources/stuff.py 42 42 4 0 0%
src/resources/utils.py 6 6 2 0 0%
tests/conftest.py 89 9 8 0 89%
tests/test_bla.py 3 0 0 0 100%
tests/test_core_file.py 625 14 104 0 97%
tests/test_stuff.py 26 0 0 0 100%
tests/test_utils.py 38 1 4 0 98%
--------------------------------------------------------------------------------
TOTAL 1542 785 371 0 45%
Local machine
Name Stmts Miss Branch BrPart Cover
--------------------------------------------------------------------------------
__init__.py 0 0 0 0 100%
setup.py 10 10 4 0 0%
src/__init__.py 0 0 0 0 100%
src/bla.py 2 0 0 0 100%
src/core_file.py 701 137 205 43 78%
src/resources/__init__.py 0 0 0 0 100%
src/resources/stuff.py 41 0 10 0 100%
src/resources/utils.py 6 0 2 0 100%
tests/__init__.py 0 0 0 0 100%
tests/conftest.py 72 9 2 0 85%
tests/test_bla.py 3 0 0 0 100%
tests/test_core_file.py 5 74 14 18 0 98%
tests/test_stuff.py 26 0 0 0 100%
tests/test_utils.py 38 1 6 0 98%
--------------------------------------------------------------------------------
TOTAL 1473 171 247 43 86%
I have the following files set:
setup.cfg
[tool:pytest]
addopts =
# Configure pytest to verbose output
-v
# Configure pytest-cov to report coverage for src
--cov=.
# Configure pytest-cov to output coverage results to stdout
--cov-report term
# Configure pytest-cov to generate an html report in /htmlcov
--cov-report html
# Configure pytest-cov to fail, if the under coverage falls under the value below
--cov-fail-under=87
testpaths = tests/
tox.ini
[tox]
envlist = 3.6.15, 3.10.2
[testenv]
deps =
-rrequirements.test.txt
-rrequirements.txt
commands =
pytest tests/ -k "not tobefixed"
coverage report
[testenv:clean]
deps = coverage
skip_install = true
commands = coverage erase
setup.py
from os.path import splitext, basename
from pathlib import Path
import os
from setuptools import setup, find_packages
from setuptools.glob import glob
VERSION = '2.16.0'
setup(
python_requires='>=3.6',
description='[OMITTED]',
keywords='[OMITTED]',
name='[OMITTED]',
version=VERSION,
url='[OMITTED]',
classifiers=[
# Python versions supported.
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.10',
],
packages=find_packages('src'),
package_dir={'': 'src'},
py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')],
package_data={'[OMITTED]': ['py.typed']},
include_package_data=True,
zip_safe=False,
install_requires=[
'requests~=2.25',
'importlib-metadata >= 1.0 ; python_version > "3.6"', # Backport used in _version.py
],
extras_require={
'dev': [
'flake8-bugbear ~= 20.11',
'flake8-import-order ~= 0.18.1',
'flake8-logging-format ~= 0.6.0',
'flake8 ~= 3.8',
'isort ~= 5.6',
'tox-pyenv',
'tox ~= 3.25',
'pytest-cov',
'pytest',
'freezegun==1.1.0',
'pytest-freezegun==0.4.2',
'twine',
]
})
Any ideas what might be wrong?
I tried adding a .coveragerc but then it only shows zeros at the src files and only 2 test files, instead of everything, so not sure what's wrong.
Thanks!