-
Notifications
You must be signed in to change notification settings - Fork 211
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
Multiple cov fail under flags Fixes #323 #330
Multiple cov fail under flags Fixes #323 #330
Conversation
3d2581f
to
b3bd9e0
Compare
40ac848
to
c2846e2
Compare
"Required test coverage of 100.0%:+test/* reached. Total coverage: 100.00%", | ||
"Required test coverage of 100.0%:+test/* reached. Total coverage: 100.00%", | ||
"Required test coverage of 33.33%:-test/* reached. Total coverage: 33.33%", | ||
]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So to understand what the argument do - in this test it's like this right?
- overall coverage must be at least 55.55%
- test coverage must be 100%
- test coverage must be 100% (alternative syntax with "+")
- overall coverage but without tests must be at least 33.33%
Also if I understand it correctly "%" is optional, and "+" as well yes?
And --cov-fail-under=100:foo:bar
means coverage must be 100% for foo
and bar
right? It should be part of the test suite.
There are few things that I think users will find confusing or produce undesired results:
- the multiple syntax to obtain the same thing
- the reporting discrepancy - you can set fail-under for something that you cannot see in the reporting - suddenly you can't know what to fix to make the suite pass
Do we really need the omit mode (the "-" syntax)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So to understand what the argument do - in this test it's like this right?
* overall coverage must be at least 55.55% * test coverage must be 100% * test coverage must be 100% (alternative syntax with "+") * overall coverage but without tests must be at least 33.33%
Also if I understand it correctly "%" is optional, and "+" as well yes?
And
--cov-fail-under=100:foo:bar
means coverage must be 100% forfoo
andbar
right? It should be part of the test suite.There are few things that I think users will find confusing or produce undesired results:
* the multiple syntax to obtain the same thing
I don't think it's confusing. You get the same with +1 and 1
* the reporting discrepancy - you can set fail-under for something that you cannot see in the reporting - suddenly you can't know what to fix to make the suite pass
I don't believe you can
Do we really need the omit mode (the "-" syntax)?
Yes so you can get an idea of coverage for code without tests. This is the coverage result people ignore the test suite for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most people upgrading to this syntax will have ignored tests globally and will still want to assert on that number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes so you can get an idea of coverage for code without tests. This is the coverage result people ignore the test suite for.
Most people have just one top level package thus omit is unnecessary.
I don't believe you can
The reporting show percentages for individual files, doesn't show any totals for packages, subpackages and so on. This is why I don't think this is a great idea.
@nedbat do you have any input on this syntax? I don't want to have something in pytest-cov that will never ever be part of coveragepy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes so you can get an idea of coverage for code without tests. This is the coverage result people ignore the test suite for.
Most people have just one top level package thus omit is unnecessary
That doesn't follow:
Most people have just one top level package
thus some people do not have just one top level package
thus omit is necessary
Also omit is needed for the http://doc.pytest.org/en/latest/goodpractices.html#tests-as-part-of-application-code layout
I don't believe you can
The reporting show percentages for individual files, doesn't show any totals for packages, subpackages and so on. This is why I don't think this is a great idea.
No the reporting lists a percentage for each --cov-fail-under
@nedbat do you have any input on this syntax? I don't want to have something in pytest-cov that will never ever be part of coveragepy.
This interface is already available in coveragepy: you just run "coverage report" with different include/omit overrides
c2846e2
to
7989cb6
Compare
I'm also suffering of Sadly this PR (at commit 7989cb6 at least) breaks
Uninstalling
Of course in this day and age computers tend to have more than one core, so it would be super nice if Thanks for taking on this work, though, much appreciated! |
@mjtorn do you have more of that stacktrace? |
@graingert sure. Wasn't thinking it's necessary cuz
|
@mjtorn nice thanks for that |
You're very welcome. As a workaround, I installed that one commit of yours and run coverage reports without parallelization, which is acceptable for now, but I'll be keeping an eye on this PR, and hopefully a merge and new version will arise :) |
I think master might fix your issue if you're not using multiple
cov-fail-under options
…On Tue, 10 Sep 2019, 12:19 Markus Törnqvist, ***@***.***> wrote:
You're very welcome. As a workaround, I installed that one commit of yours
and run coverage reports without parallelization, which is acceptable for
now, but I'll be keeping an eye on this PR, and hopefully a merge and new
version will arise :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#330?email_source=notifications&email_token=AADFATCVGU5EAOW5CDKFDATQI57DPA5CNFSM4ISPVDJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6KXR4A#issuecomment-529889520>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADFATFCIBTQDQRJSO7L5BTQI57DPANCNFSM4ISPVDJA>
.
|
@mjtorn it looks like it's supposed to be fixed pytest-dev/pytest-xdist#384 |
Doesn't look like a win, got 1.28.0 here, but maybe someone will react on that issue. Subscribed to its notifications, thanks :) |
7989cb6
to
34a0399
Compare
@mjtorn try that |
Likewise The weird thing here is that with both your commit and vanilla I'll be away for quite a few days starting later today, so I don't know how much testing and reporting I can get done. The variations in the coverage reports are quite strange, and I have no proper explanation for them. It could be whoever wrote some of these tests wrote them to leak state that affects the code paths for different To sum it up, your latest change feels nice. Are there many blockers for getting it merged? Issues I should be aware of? |
As part of my proposal that pytest-cov should do less (#337), I think this shouldn't be merged. This entire feature can be a separate tool. It's got nothing to do with running tests. |
This might be due to term-missing mutating the cov config in pytest-cov==2.7.1 What's the subtle difference? |
94f5ff3
to
cd52a7c
Compare
@graingert I should be back on this tomorrow, but before going away, I got quite sure the problem was in the tests themselves. I'll let you know, but taking a quick look at #338 I have no idea what I should be looking out for. When do the configs mutate? @nedbat I'll read through #337 later, but having two severe bugs such as "fail the test if it's less than n.d" failing because |
@nedbat I did not write the issues up because it looked like they're being tackled quickly here. Bug 1: Asking pytest-cov to fail if the coverage is beneath a threshold works only for integers. Quite severe! Bug 2: xdist didn't work. Blocker-level. The other fluff about indeterminate results is - with a guesstimated certainty of 99% - someone else's inexperience in writing isolated tests in an existing code base and irrelevant to pytest, coverage or any combination thereof. |
@mjtorn Bug 1 should be fixed in master already. master is also not impacted by Bug 2 |
@mjtorn Bug 1 is a great example of why pytest-cov shouldn't be doing all this. Coverage.py has allowed a float for fail-under since version 4.5, 2018-02-03. Why should we have to also update the UI of the plugin, just so it can pass it along to coverage.py? If you do your reporting as a separate explicit step using coverage.py directly, then you don't have to wait for two projects to update in order to use the feature. There's no reason for pytest-cov to be handling this value. |
@graingert you're absolutely right. I got carried away finding everything under the sun except checking the master branch first ;) @nedbat I'm happy to see that the master branch should work, so all philosophizing is moot. I will say that I disagree with needing an extra step to deal with or work around something that's a part of the documented CLI interface, only because it's buggy in the 2.7.1 release. I don't have time to think about where to draw lines for this stuff, but software should be convenient to use and implementing Best of luck to figuring things out and I'll pop back in if I have the need to. Thanks! |
cd52a7c
to
637cefc
Compare
0fdddb4
to
3f24c0a
Compare
@graingert I'll reiterate my strong belief that it doesn't make sense for pytest-cov to be doing this. Pytest should run tests and report on whether they pass or fail. Coverage reporting commands can deal with coverage reporting. |
3f24c0a
to
9183ae5
Compare
@nedbat I couldn't disagree more. However I wouldn't object to moving the summary method into the coverage.Coverage class and implementing multiple reporting there |
9183ae5
to
0a0be4d
Compare
@graingert We should come to an agreement. This issue (#337) had overwhelming support for removing reporting features from pytest-cov. There's no reason for it to implement them. Whatever people are using to run pytest, they can use that thing to also run coverage reporting commands afterward. This just adds needless complexity and awkard interfaces. pytest-cov's job should be integrating pytest with coverage where that integration is needed. It should not be a one-stop shop for everything people want to do with coverage. |
Closing this as this was not touched in more than two years, so I doubt it would suddenly become something ready for review. Feel free reopen if you disagree. Doing this to cleanup the queue, so we can focus on reviewing things that are ready for review and merge. |
Allows you to run
pytest --cov-fail-under=70 --cov-fail-under=100:test/**
.Fixes #323.