You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
--cov as final element in addopts creates confusing behaviour #701
I think then it might be a problem of pytest-cov since they recommend not giving it when using source configuration:
If you have multiple sources it might be easier to set those in .coveragerc and always use --cov (without a value) instead of having a long command line with --cov=pkg1 --cov=pkg2 --cov=pkg3 ....
Do you +1 or am I missing something else? If appropriate, I will maybe ask for help or open an issue directly at pytest-cov.
Also, I think my case can easily be solved simply by swapping the order of my options in my config file so that --cov is already followed by another option? I cannot test this week-end.
Finally, maybe they could use a special character to mean "use from source" (e.g.--cov=!).
It could even be automatically added if configuration file ends with --cov, but this may not be a desirable behaviour.
changed the title [-]--cov as final emelent in addopts xcreates confusing behaviour[/-][+]--cov as final element in addopts creates confusing behaviour[/+]on Jul 2, 2025
Activity
RonnyPfannschmidt commentedon Jun 20, 2025
I believe a argument to the cov option is missing
RonnyPfannschmidt commentedon Jun 20, 2025
Indeed the cov option expects a argument
Provide that or remove it from addopts
eliegoudout commentedon Jun 20, 2025
Thanks for your answer.
I think then it might be a problem of
pytest-covsince they recommend not giving it when using source configuration:Do you +1 or am I missing something else? If appropriate, I will maybe ask for help or open an issue directly at
pytest-cov.RonnyPfannschmidt commentedon Jun 20, 2025
I believe the examples put options instead of filename after it so it works
This definitely needs better docs
RonnyPfannschmidt commentedon Jun 20, 2025
I checked the docs they use the --cov=somename variant
We probably need a warning
eliegoudout commentedon Jun 21, 2025
I think a warning could be a first step indeed.
Also, I think my case can easily be solved simply by swapping the order of my options in my config file so that
--covis already followed by another option? I cannot test this week-end.Finally, maybe they could use a special character to mean "use from source" (e.g.
--cov=!).It could even be automatically added if configuration file ends with
--cov, but this may not be a desirable behaviour.[-]Test only specific files[/-][+]--cov as final emelent in addopts xcreates confusing behaviour[/+]RonnyPfannschmidt commentedon Jun 21, 2025
ionelmc commentedon Jun 27, 2025
Would using
"--cov="(just that) achieve the desired result? It would not eat up following arguments.ionelmc commentedon Jun 27, 2025
If not maybe we could implement a special value, eg:
--cov=*or--cov=?[-]--cov as final emelent in addopts xcreates confusing behaviour[/-][+]--cov as final element in addopts creates confusing behaviour[/+]