Thanks to visit codestin.com
Credit goes to github.com

Skip to content

TST: increase coverage on tk tests #22498

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

Merged
merged 3 commits into from
Mar 23, 2022

Conversation

tacaswell
Copy link
Member

PR Summary

This will increase the reported coverage of the tk tests, but shares commits
with #22005 and should be merged after that.

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

@tacaswell tacaswell force-pushed the tst_increased_coverage_on_tk branch from 1a03e1c to 153bfa1 Compare March 4, 2022 15:35
@tacaswell tacaswell marked this pull request as ready for review March 4, 2022 15:35
Copy link
Contributor

@greglucas greglucas left a comment

Choose a reason for hiding this comment

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

Looks good to me.

source = re.search(r"(?ms)^def .*", inspect.getsource(func)).group(0)

if "MPL_TEST_ESCAPE_HATCH" in os.environ:
return func
Copy link
Contributor

Choose a reason for hiding this comment

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

So, we are checking coverage of tests too? I guess I don't fully follow what coverage is reporting here...

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, we look at the coverage on the tests as well (@dopplershift has argued that tests are the only place insisting in 100% coverage actually make senses as if all of the code in your test suite is not running what are you even doing?!).

The change here is that instead of extracting the source and shoving it through python -c we are importing the test module and then running the actual test function in a sub-process. This bit of logic is so that when pytest discovers the tests it will go through the logic to spawn a sub-process to import an run the function but we import it to run it we need to actually run it. Setting an env in the subprocess call was the simplest way I found to do this.

Copy link
Member Author

Choose a reason for hiding this comment

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

And I new see the warning that this is not actually covered and I am confused....

Copy link
Member

Choose a reason for hiding this comment

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

(@dopplershift has argued that tests are the only place insisting in 100% coverage actually make senses as if all of the code in your test suite is not running what are you even doing?!).

There can be many reasons you don't run all of your test suite at a given time. Some optional dependencies may not be available, you could have very costly tests that you run only at larger intervals, ...

Out of curiosity, does coverage stretch across all the running CI jobs or where does it get its data from?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, at the end of all of our CI jobs we have something like

      - name: Upload code coverage
        uses: codecov/codecov-action@v2

that pushes coverage information to codecov and then they merge all of them together.

If you click through the coverage UI enough you can get to https://codecov.io/gh/matplotlib/matplotlib/commit/153bfa18377c1a15a76906cfb77973971e0cee95/build which will show you which CI runs contributed to a given report.

Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

LGTM. Maybe add the one comment. Can self-merge after this.

source = re.search(r"(?ms)^def .*", inspect.getsource(func)).group(0)

if "MPL_TEST_ESCAPE_HATCH" in os.environ:
return func
Copy link
Member

Choose a reason for hiding this comment

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

(@dopplershift has argued that tests are the only place insisting in 100% coverage actually make senses as if all of the code in your test suite is not running what are you even doing?!).

There can be many reasons you don't run all of your test suite at a given time. Some optional dependencies may not be available, you could have very costly tests that you run only at larger intervals, ...

Out of curiosity, does coverage stretch across all the running CI jobs or where does it get its data from?

@tacaswell tacaswell marked this pull request as draft March 23, 2022 14:03
@tacaswell
Copy link
Member Author

🤦🏻 I cherry-picked this out wrong and lost the "give me more coverage" functionality.

@tacaswell
Copy link
Member Author

🤦🏻 I'm looking at the wrong local branch because work trees are fighting back...I need to finish my ☕ .....

@tacaswell tacaswell marked this pull request as ready for review March 23, 2022 15:22
@tacaswell
Copy link
Member Author

This should be ready to go again, the reason coverage was not showing up for the tests is that I had inverted the skip logic. I'll merged if/when CI runs and comes back green.

@tacaswell tacaswell closed this Mar 23, 2022
@tacaswell tacaswell reopened this Mar 23, 2022
@timhoffm timhoffm merged commit 647afe6 into matplotlib:main Mar 23, 2022
@tacaswell tacaswell deleted the tst_increased_coverage_on_tk branch March 23, 2022 23:01
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