Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get coverage? #68

Open
julien-carsique-sonarsource opened this issue Jul 15, 2024 · 0 comments
Open

How to get coverage? #68

julien-carsique-sonarsource opened this issue Jul 15, 2024 · 0 comments

Comments

@julien-carsique-sonarsource

Hello,

I can't get the coverage properly evaluated. Would you know how to fix this?
There are mainly two tests, one with the defaults and one with custom parameters.

Thank you,


tests/test_cookiecutter.py:

def test_defaults(cookies):
    result = cookies.bake()
    assert...

def test_customization(cookies):
    result = cookies.bake(extra_context={...})

pyproject.toml:

[tool.poetry.dependencies]
python = "^3.10"
pytest-cookies = "^0.7.0"

[tool.poetry.group.test.dependencies]
pytest = "^7.4.2"
pytest-cov = "^4.1.0"
pytest-httpserver = "^1.0.8"
coverage = {extras = ["toml"], version = "^6.5.0"}
pytest-mock = "^3.11.1"

[tool.pytest.ini_options]
log_cli = true
minversion = "6.0"
addopts = """
  --cov-report html:build/coverage-html
  --cov-report xml:build/coverage.xml
  --cov-report term
  --cov=hooks
  --cov-branch
"""
testpaths = ["tests"]
$ poetry run pytest
platform linux -- Python 3.10.10, pytest-7.4.4, pluggy-1.5.0
rootdir: ...
configfile: pyproject.toml
testpaths: tests
plugins: mock-3.14.0, cookies-0.7.0, cov-4.1.0, pytest_httpserver-1.0.10
collected 2 items                                                                                                                                                                                                                                                                        

tests/test_cookiecutter.py::test_defaults PASSED [ 50%]
tests/test_cookiecutter.py::test_customization PASSED [100%]
.../.cache/pypoetry/virtualenvs/cookiecutter-sonar--COI_dO4-py3.10/lib/python3.10/site-packages/coverage/control.py:801: CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")


---------- coverage: platform linux, python 3.10.10-final-0 ----------
Name                        Stmts   Miss  Cover
-----------------------------------------------
hooks/post_gen_project.py      33     33     0%
hooks/pre_gen_project.py        0      0   100%
-----------------------------------------------
TOTAL                          33     33     0%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant