-
Notifications
You must be signed in to change notification settings - Fork 228
Multiple cov fail under flags Fixes #323 #330
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| import re | ||
| import subprocess | ||
| import sys | ||
| import textwrap | ||
| from itertools import chain | ||
|
|
||
| import coverage | ||
|
|
@@ -421,6 +422,57 @@ def test_cov_min_float_value(testdir): | |
| ]) | ||
|
|
||
|
|
||
| @xdist_params | ||
| def test_cov_min_multi(testdir, opts): | ||
| module = testdir.mkpydir("legacy") | ||
| module.join("uncovered.py").write( | ||
| textwrap.dedent( | ||
| """\ | ||
| import sut | ||
|
|
||
| def some_legacy_code(): | ||
| strategy = sut.AbstractFactoryBean() | ||
| assert strategy.business_critical() | ||
| """ | ||
| ) | ||
| ) | ||
| module.join("covered.py").write( | ||
| textwrap.dedent( | ||
| """\ | ||
| def two_returner_strategy(): | ||
| return 2 | ||
| """ | ||
| ) | ||
| ) | ||
| testsubdir = testdir.mkdir("test") | ||
|
|
||
| testsubdir.join("test_legacy.py").write( | ||
| textwrap.dedent( | ||
| """\ | ||
| from legacy import covered | ||
|
|
||
| def test_two_returner_strategy(): | ||
| assert covered.two_returner_strategy() == 2 | ||
| """ | ||
| ) | ||
| ) | ||
| result = testdir.runpytest('-v', | ||
| '--cov=%s' % str(testdir.tmpdir), | ||
| '--cov-report=term-missing', | ||
| '--cov-fail-under=55.55', | ||
| '--cov-fail-under=100.0:test/*', | ||
| '--cov-fail-under=100.0:+test/*', | ||
| '--cov-fail-under=33.33:-test/*', | ||
| testsubdir, *opts.split()) | ||
| assert result.ret == 0 | ||
| result.stdout.fnmatch_lines([ | ||
| "Required test coverage of 55.55% reached. Total coverage: 55.56%", | ||
| "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%", | ||
| ]) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Also if I understand it correctly "%" is optional, and "+" as well yes? And There are few things that I think users will find confusing or produce undesired results:
Do we really need the omit mode (the "-" syntax)?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I don't think it's confusing. You get the same with +1 and 1
I don't believe you can
Yes so you can get an idea of coverage for code without tests. This is the coverage result people ignore the test suite for.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Most people have just one top level package thus omit is unnecessary.
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.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That doesn't follow:
No the reporting lists a percentage for each --cov-fail-under
This interface is already available in coveragepy: you just run "coverage report" with different include/omit overrides |
||
|
|
||
|
|
||
| def test_cov_min_float_value_not_reached(testdir): | ||
| script = testdir.makepyfile(SCRIPT) | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.