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

Test coverage reported as <100% when argcomplete is installed #187

Closed
mtelka opened this issue Sep 4, 2023 · 5 comments
Closed

Test coverage reported as <100% when argcomplete is installed #187

mtelka opened this issue Sep 4, 2023 · 5 comments
Assignees
Labels
chore needs-design needs design decision

Comments

@mtelka
Copy link
Contributor

mtelka commented Sep 4, 2023

I'm packaging argh for OpenIndiana and during testing of version 0.29.3 I noticed the coverage fails:

---------- coverage: platform sunos5, python 3.9.16-final-0 ----------
Name                      Stmts   Miss  Cover
---------------------------------------------
src/argh/__init__.py          7      0   100%
src/argh/assembling.py      154      0   100%
src/argh/completion.py       16      2    88%
src/argh/constants.py        30      0   100%
src/argh/decorators.py       31      0   100%
src/argh/dispatching.py     126      0   100%
src/argh/exceptions.py        7      0   100%
src/argh/helpers.py          21      0   100%
src/argh/interaction.py      27      0   100%
src/argh/io.py                2      0   100%
src/argh/utils.py            24      0   100%
---------------------------------------------
TOTAL                       445      2    99%

FAIL Required test coverage of 100% not reached. Total coverage: 99.55%
================== 111 passed, 3 xfailed, 4 warnings in 1.34s ==================
@neithere
Copy link
Owner

neithere commented Sep 4, 2023

Hmm. The latest build in CI for Python 3.9 says:

platform linux -- Python 3.9.17, pytest-7.4.1, pluggy-1.3.0
...
Required test coverage of 100% reached. Total coverage: 100.00%

Not sure if the difference is related to sunos5. Do you have the results for Argh 0.28 in the same environment? Do you have more detailed information about the missed statements?

This argh.completion where coverage is missing is a tiny module with barely any logic, so it's probably either sh being used instead of bash in that environment, or argcomplete not being installed.

@neithere neithere added the needs-more-info Cannot assign a more concrete label until more details are provided. label Sep 4, 2023
@mtelka
Copy link
Contributor Author

mtelka commented Sep 5, 2023

The more complete report shows these two lines as missing:

70 except ImportError: 
71     argcomplete = None

@neithere
Copy link
Owner

neithere commented Sep 5, 2023

Hm, interesting. Looks like in your environment argcomplete is present and in the default CI environments for Argh it's not.

It may be a good idea to add a tox env with extras=completion.

OTOH, the only thing it would check is whether COMPLETION_ENABLED is set to the correct value depending on whether it was possible to import argcomplete. It's such a trivial bit of logic that I'm rather leaning towards adding # pragma: no cover to these lines that you've mentioned. The behaviour with and without argcomplete is tested with a mock in any case.

@neithere neithere changed the title coverage of 100% not reached Test coverage reported as <100% when argcomplete is installed Sep 5, 2023
@neithere neithere added needs-design needs design decision chore and removed needs-more-info Cannot assign a more concrete label until more details are provided. labels Sep 5, 2023
@neithere neithere self-assigned this Sep 5, 2023
@mtelka
Copy link
Contributor Author

mtelka commented Sep 5, 2023

Yes, exactly. The argcomplete is installed here.

@neithere
Copy link
Owner

I've excluded that line from coverage, it really makes no sense to add a whole tox env to test that pretty obvious bit of code. Thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore needs-design needs design decision
Projects
None yet
Development

No branches or pull requests

2 participants