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

Report code coverage #36

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[run]
source =
SOURCES/
tests/

[report]
# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover

# Don't complain if tests don't hit defensive assertion code:
raise AssertionError
raise NotImplementedError
\<assert\>.*

# Don't complain if non-runnable code isn't run:
if 0:
if __name__ == .__main__.:

precision = 1
include =
SOURCES/*
tests/*
5 changes: 2 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install mock pytest pyfakefs
pip install pathlib mock pytest pytest-cov pyfakefs
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: pytest
run: |
cd tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the cd tests is no longer required?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand it, it is essentially useful to restrict test discovery, which can be done as well on pytest commandline (though this is not even necessary, there is just no other tests to be discovered in other dirs).
OTOH it requires a .coveragerc to be under tests/ as well, which means a dev has to use this cd tests in everyday life as well.

Copy link
Member

@Wescoeur Wescoeur Jul 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cd tests is related to this issue: pytest-dev/pyfakefs#666
It's merged for several months, in theory we can remove this instruction if we use the latest version of pyfakefs.

pytest
pytest --cov --cov-report=xml --cov-report=term tests
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
**/__pycache__
*.pyc
/.coverage
/coverage.xml