-
-
Notifications
You must be signed in to change notification settings - Fork 433
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
coverage-7.3.3 broke pragma: no cover in match-case statement #1713
Comments
Here is a test for the test suite that demonstrates the problem: @ tests/test_coverage.py:1743 @ def my_func_2(super_long_input_argument_0=0, super_long_input_argument_1=1, supe
[], "5", excludes=['my_func']
)
+ def test_excluding_clause_bug1713(self) -> None:
+ self.check_coverage("""\
+ print("1")
+
+ def hello_3(a): # no thanks
+ if ("4" or
+ "5"):
+ print("6")
+ else:
+ print("8")
+
+ print("10")
+ """,
+ [1, 10], "", excludes=["no thanks"],
+ )
+
def test_excluding_method(self) -> None:
self.check_coverage("""\
class Fooey: @kajakaj, @maciekgyver, do you have an idea how to handle this case? |
See nedbat/coveragepy#1713. Signed-off-by: William Woodruff <william@trailofbits.com>
Not sure if related, but I also have a new coverage miss on coverage 7.3.3 Code: if condition_a: # pragma: no cover; local only
func1()
if (
condition_b
== 0
):
return
func2() # this statement is now shown as not covered On prior versions, the whole if block was ignored correctly. |
We have seen this regression for a class as well, so seems like anything block level. class Foo: # pragma: no cover
def greet(self):
print("hello world") |
Hi all, sorry for the regression. I'm working on a fix. The code uses tokenize to analyze the code, which isn't holding up well. I'm working on switching it to use the AST instead. |
Not sure this is exactly the same problem, but in case it helps, we're also seeing a regression in the Briefcase test suite. However, we're only seeing it on Windows. I'll try to reduce this to a simple reproduction case. |
I haven't narrowed this down to a specific reproduction case yet, but it appears to be related to an interaction with coverage-conditional-plugin. This is the coverage file for the failing run; it has 100% coverage on coverage 7.3.2, but has the 2 missing blocks of lines on coverage 7.3.3, (conditional-coverage-plugin=0.9.0), with a conditional rule of |
I am also seeing a regression in coverage (only in CI though?) for a case like: class MyClass: # pragma: no cover
def method(self):
pass Which was previously ignoring the lines in |
FWIW: The pattern that @ringohoffman has described is very similar to what is happening in my case; however, I haven't been able to generate a simple reproduction case that fails. In case it helps someone else: in my case, the The code that is being mistakenly marked as a coverage miss is:
The second one is particularly odd, because there's plenty of other lines in the method (both before and after the problematic context managers) that are marked as covered, as well as other context managers in the same method. |
* _virtual_env: add --no-input to all invocations Closes #706. Signed-off-by: William Woodruff <william@trailofbits.com> * CHANGELOG: record changes Signed-off-by: William Woodruff <william@trailofbits.com> * pyproject: filter coverage==7.3.2 See nedbat/coveragepy#1713. Signed-off-by: William Woodruff <william@trailofbits.com> --------- Signed-off-by: William Woodruff <william@trailofbits.com>
Although as you can see from my example above it doesn't have to be a class, it can be any kind of nested block (an |
Just to make it clear, the case in the issue description was run on Linux. |
Another occurrence, which was quite confusing: I have several classes in one file, inheriting after abstract and all individually marked with Go figure. Code is in private repository, but I can look for potential triggers of this behaviour, if directed. The first class has multiline definition of My case, somewhat simplified:
Results:
No idea how to reproduce the "fix" yet (as in, how to add methods that are still excluded from the final coverage and in between erroneous blocks); I tried adding another class in between, did not change behaviour to the one observed. |
I've made a simple fix on the nedbat/bug1713 branch. BUT: only one of the examples shown in the comments here (the match/case in the original description) was broken for me in 7.3.3. I don't see why there would be an OS sensitivity in either the original bug or the fix. To try the fixed code:
Please let me know what you find. |
@nedbat Can confirm that branch seems to address the problem for me. Thanks for the fast turnaround under very obscure reproduction circumstances :-) |
Thanks for the confirmation, but it kind of just deepens the mystery... |
I can confirm this fixes the issue for my reported sample (e406af2) |
This is fixed in commit 07b76b2. |
I can confirm that the |
This is now released as part of coverage 7.3.4. |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [coverage](https://togithub.com/nedbat/coveragepy) | `==7.3.3` -> `==7.3.4` | [![age](https://developer.mend.io/api/mc/badges/age/pypi/coverage/7.3.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/pypi/coverage/7.3.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/pypi/coverage/7.3.3/7.3.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/coverage/7.3.3/7.3.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>nedbat/coveragepy (coverage)</summary> ### [`v7.3.4`](https://togithub.com/nedbat/coveragepy/blob/HEAD/CHANGES.rst#Version-734--2023-12-20) [Compare Source](https://togithub.com/nedbat/coveragepy/compare/7.3.3...7.3.4) - Fix: the change for multi-line signature exclusions in 7.3.3 broke other forms of nested clauses being excluded properly. This is now fixed, closing `issue 1713`\_. - Fix: in the HTML report, selecting code for copying won't select the line numbers also. Thanks, `Robert Harris <pull 1717_>`\_. .. \_issue 1713:[https://github.com/nedbat/coveragepy/issues/1713](https://togithub.com/nedbat/coveragepy/issues/1713)3 .. \_pull 1717[https://github.com/nedbat/coveragepy/pull/1717](https://togithub.com/nedbat/coveragepy/pull/1717)17 .. \_changes\_7-3-3: </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/allenporter/flux-local). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMDMuMSIsInVwZGF0ZWRJblZlciI6IjM3LjEwMy4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* _virtual_env: add --no-input to all invocations Closes #706. Signed-off-by: William Woodruff <william@trailofbits.com> * CHANGELOG: record changes Signed-off-by: William Woodruff <william@trailofbits.com> * pyproject: filter coverage==7.3.2 See nedbat/coveragepy#1713. Signed-off-by: William Woodruff <william@trailofbits.com> --------- Signed-off-by: William Woodruff <william@trailofbits.com>
* _virtual_env: add --no-input to all invocations Closes #706. Signed-off-by: William Woodruff <william@trailofbits.com> * CHANGELOG: record changes Signed-off-by: William Woodruff <william@trailofbits.com> * pyproject: filter coverage==7.3.2 See nedbat/coveragepy#1713. Signed-off-by: William Woodruff <william@trailofbits.com> --------- Signed-off-by: William Woodruff <william@trailofbits.com>
* _virtual_env: add --no-input to all invocations Closes #706. Signed-off-by: William Woodruff <william@trailofbits.com> * CHANGELOG: record changes Signed-off-by: William Woodruff <william@trailofbits.com> * pyproject: filter coverage==7.3.2 See nedbat/coveragepy#1713. Signed-off-by: William Woodruff <william@trailofbits.com> --------- Signed-off-by: William Woodruff <william@trailofbits.com>
coverage-7.3.3 released few hours ago broke ignoring whole function by
# pragma: no cover
when the function containsmatch..case
statement with case condition on multiple lines. My minimum example:Then run coverage and you'll get report with last two match-case lines uncovered even though the whole function should be ignored.
Worked fine in coverage-7.3.2.
The text was updated successfully, but these errors were encountered: