Skip to content

Also record coverage for tests #3875

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

Closed
wants to merge 1 commit into from
Closed

Also record coverage for tests #3875

wants to merge 1 commit into from

Conversation

asottile
Copy link
Member

As seen in #3873, there's sneaky dead code lurking in ./testing. Let's surface that a little bit better.

I started combing through the results but didn't get terribly far.

@blueyed
Copy link
Contributor

blueyed commented Aug 25, 2018

I've picked up #2800 again.
I would say to wait with this here until it is in.

I think we should also add branch=1 separately, and I wanted to do it after #2800 to have better reporting for what it changes.

@coveralls
Copy link

coveralls commented Aug 25, 2018

Coverage Status

Coverage increased (+1.2%) to 93.812% when pulling 3bb4d8a on asottile:coverage_for_tests into a319674 on pytest-dev:master.

.coveragerc Outdated
@@ -1,4 +1,26 @@
[run]
branch = True
source = .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better use _pytest,testing here - less to omit then.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm but then you have to have a special snowflake .coveragerc for each project

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

I think it is OK for a project to have its own sources defined here - after all you would then have special omits instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷‍♂️ no special omits here -- I copied this from one of my projects

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still different than "defaults", no? :)

.coveragerc Outdated
^if __name__ == ['"]__main__['"]:$

# Intentionally skipped tests
^\s*@pytest\.mark\.skipif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pytest\.mark\.skipif should not be excluded: one of the builds should hit it.
(more relevant with/after #2800)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a reason to block on #2800 -- until then this improves local runs of isolated environments.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is not blocked by #2800, but with #2800 you would not have added it in the first place, would you? (because it should be covered then, and if not it would mean no test setup is hitting it).

@@ -2,7 +2,7 @@

try:
from ._version import version as __version__
except ImportError:
except ImportError: # pragma: no cover
# broken installation, we don't even try
# unknown only works because we do poor mans version compare
__version__ = "unknown"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better leave this code as uncovered.
We're not trying to hit 100%, but is is OK for this to be not covered - also for other things below.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not trying to hit 100%

We're not? 😆

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmation that, in fact, we are:

#2800 (review)

Ultimately we should strive to obtain 100% coverage...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/cc @nicoddemus

I think the crucial part from there is:

Even if we "cheat", we gain the benefit of demanding that new code from now on has 100% coverage.

This should be achieved instead by requiring a diff to be covered 100% - something which codecov provides then.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, it is ok to add some # pragma: no cover here and there for code that we can't really cover on tests in a practical manner, here is a prime example of that: this is just a safe guard for broken pytest installations.

@@ -88,7 +88,7 @@ def __call__(self, prefix, **kwargs):
return completion


if os.environ.get("_ARGCOMPLETE"):
if os.environ.get("_ARGCOMPLETE"): # pragma: no cover
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one e.g. would be good to get covered in the long run.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you think this could be covered in the long run?

Copy link
Contributor

@blueyed blueyed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be trimmed down to only expanding sources to _pytest,testing.
And it should get rebased on master after we have basic codecov, via #3877.

@nicoddemus
Copy link
Member

I think this should be trimmed down to only expanding sources to _pytest,testing.

Agree 👍

@asottile
Copy link
Member Author

I've rebased and set source = _pytest,testing

Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks @asottile!

@asottile
Copy link
Member Author

@blueyed -- I'll defer to your review -- let me know if/when this is mergeable!

@codecov
Copy link

codecov bot commented Aug 27, 2018

Codecov Report

Merging #3875 into master will decrease coverage by 0.36%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3875      +/-   ##
==========================================
- Coverage   92.59%   92.22%   -0.37%     
==========================================
  Files          51      104      +53     
  Lines        9960    23189   +13229     
  Branches        0     2285    +2285     
==========================================
+ Hits         9222    21386   +12164     
- Misses        738     1436     +698     
- Partials        0      367     +367
Impacted Files Coverage Δ
src/_pytest/__init__.py 100% <ø> (+40%) ⬆️
src/_pytest/_code/code.py 92.47% <ø> (-1.27%) ⬇️
src/_pytest/_argcomplete.py 95.83% <ø> (+15.83%) ⬆️
testing/test_skipping.py 97.84% <ø> (ø)
src/_pytest/assertion/__init__.py 86.36% <0%> (-10.61%) ⬇️
src/_pytest/pastebin.py 85.48% <0%> (-8.07%) ⬇️
src/_pytest/warnings.py 70.17% <0%> (-7.02%) ⬇️
src/_pytest/assertion/truncate.py 92.15% <0%> (-5.89%) ⬇️
src/_pytest/config/argparsing.py 87.78% <0%> (-5.89%) ⬇️
src/_pytest/debugging.py 55.81% <0%> (-4.66%) ⬇️
... and 88 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a319674...3bb4d8a. Read the comment docs.

@blueyed
Copy link
Contributor

blueyed commented Aug 27, 2018

@asottile
I've meant to only change source, nothing more.
This would then show which tests are not covered.
The next step would then be adding branch = 1 (maybe also in this PR), but nothing more.

@asottile
Copy link
Member Author

what's the reason?

@blueyed
Copy link
Contributor

blueyed commented Aug 27, 2018

@asottile
I would rather keep it simpler - but that's just my opinion.

@asottile
Copy link
Member Author

I'm sorry, can you highlight what portions of the PR you're in opposition to and your rationale for opposing them? I'm not sure I'm understanding :(

Copy link
Contributor

@blueyed blueyed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asottile
Sorry for coming across negatively.

I think we should get #2800 in first, then a separate PR adding branch = 1 to clearly see what it changes, and then we can discuss this one further.
In general I think we should not use # pragma: no cover at first.

@@ -88,7 +88,7 @@ def __call__(self, prefix, **kwargs):
return completion


if os.environ.get("_ARGCOMPLETE"):
if os.environ.get("_ARGCOMPLETE"): # pragma: no cover
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you think this could be covered in the long run?

@@ -99,7 +99,7 @@ def try_argcomplete(parser):
argcomplete.autocomplete(parser, always_complete_options=False)


else:
else: # pragma: no cover
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

@nicoddemus
Copy link
Member

I gather that now that #3920 has been merged we can pick this up again?

@asottile
Copy link
Member Author

asottile commented Sep 1, 2018

I guess there's no point now that @blueyed cherry picked all the parts out

@asottile asottile closed this Sep 1, 2018
@asottile asottile deleted the coverage_for_tests branch September 1, 2018 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants