question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing code-coverage within `pytest_sessionfinish`

See original GitHub issue

Summary

Code present within project.specific.conftest::pytest_sessionfinish() is shown as “not covered”, although it is executed.

Comparing pytest-cov with coverage,

Code within pytest_sessionfinish is presented as covered when python-coverage is used with the following command

coverage run --include conftest.py -m pytest test_dummy.py && coverage html -d cov_report

Link to test_dummy.py.

Expected vs actual result

Code executed within pytest_sessionfinish should be presented as covered.

Reproducer

README files consists of the instructions to setup the virtual-environment and pytest framework.

Other files of interest within the referred repository:

  • pyproject.toml: consists of pytest-cov related switches

Versions

Requirements file can be accessed here: https://github.com/dshah244/dummy_pytest/blob/master/req_dev.txt

Output of pip freeze:

-e .
iniconfig==1.1.1
packaging==21.3
pluggy==1.0.0
py==1.11.0
pyparsing==3.0.6
pytest==6.2.5
pytest-cov==3.0.0
pytest-html==3.1.1
pytest-metadata==1.11.0
toml==0.10.2
tomli==1.2.2

python --version= pytest 6.2.5

pytest --version= Python 3.10.0

Config

https://github.com/dshah244/dummy_pytest/blob/master/pyproject.toml

Code

https://github.com/dshah244/dummy_pytest

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ionelmccommented, Feb 2, 2022

You might want to copy some of the tricks here: https://pytest-cov.readthedocs.io/en/latest/plugins.html

0reactions
dshah244commented, Feb 10, 2022

You might want to copy some of the tricks here: https://pytest-cov.readthedocs.io/en/latest/plugins.html

Thanks for the tip @ionelmc 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

In a pytest coverage report, what does "->" mean for missing ...
Coverage collects pairs of transition in your code that goes from one line (the source) to another (the destination).
Read more >
Usage and Invocations — pytest documentation
Running pytest can result in six different exit codes: Exit code 0. All tests were collected and passed successfully. Exit code 1. Tests...
Read more >
Code coverage stays to 0%, what am I missing? - SonarCloud
In a nutshell : Error : SonarCloud Dashboard showing 0% Coverage GitHub (private repo) Github Actions Python (for a data science project) Hi ......
Read more >
pytest-cov 4.0.0 - PythonFix.com
Pytest plugin for measuring coverage. ... No pytest-cov pypi packages just yet. ... Missing code-coverage within pytest_sessionfinish ...
Read more >
"Analyze Code Coverage" no longer on Test menu
Thank you for your feedback! Do you see the Analyze Code coverage menus in the TestExplorer on context clicking a test/group of tests?...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found