8000 Add initial TextBox widget testing by dmatos2012 · Pull Request #20451 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Add initial TextBox widget testing #20451

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 2 commits into from
Jun 30, 2021

Conversation

dmatos2012
Copy link
Contributor

PR Summary

This PR addresses the test coverage of TextBox widget on Issue #20370. This is my first contributing issue, so I grabbed initial approach by the issue opener. I would gladly change whatever is needed.

PR Checklist

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • Conforms to Matplotlib style conventions (install flake8-docstrings and run flake8 --docstring-convention=all).
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).

Copy link
@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a while, please feel free to ping @matplotlib/developers or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide

We strive to be a welcoming and open project. Please follow our Code of Conduct.

assert tool.color == '1.0'


def test_TextBox():
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason to nest these like this rather than just call the above test_TextBox?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not particularly, I have changed that now. Thanks!

tool.begin_typing(tool.text)
tool.stop_typing()
assert tool.text == 'x**1'
assert tool.color == '1.0'
Copy link
Member

Choose a reason for hiding this comment

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

Probably should assert this before it changes, as well.

assert tool.text == 'x**2'
tool.on_submit(submit)
tool.on_text_change(change)
tool.begin_typing(tool.text)
Copy link
Member

Choose a reason for hiding this comment

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

It doesn't really make sense to enter text into the box, and not verify that that actually ended up in the box, but instead, replace the text entirely on the submit handler.

If you want to verify that the handlers were called, then set a global, or use a Mock object that counts calls. And to verify that the setters work, just call them directly (and assert a check after.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes thank you so much, I have modified according to your suggestions.

@dmatos2012
Copy link
Contributor Author

I have updated the code to take into consideration both comments. I eliminated the indentations and used Mock objects to count calls as per the suggestion.

@tacaswell
Copy link
Member

@dmatos2012 The source of the missing coverage is that first time contributors do no trigger the GHA steps without intervention from the maintainers (because people were abusing the system by opening up PRs against projects that would gut their CI and replace it with crypto mining 🤦🏻 ) .

Hopefully with the extra runs we will get your coverage up!

@tacaswell tacaswell added this to the v3.5.0 milestone Jun 28, 2021
@tacaswell
Copy link
Member

@dmatos2012 Are you comfortable rebasing this PR? The fix for those failed tests is already merged to the default branch.

@dmatos2012
Copy link
Contributor Author

Hi @tacaswell I just did it, I think my heart rate is now 190 bpm, but I hope I did it correct. If there is anything else I need to update, change please let me know :). Thanks !

@tacaswell
Copy link
Member

@dmatos2012 rebasing and force pushing will eventually become less terrifying ;)

@QuLogic QuLogic merged commit 077393e into matplotlib:master Jun 30, 2021
@dmatos2012 dmatos2012 deleted the testcov_textbox branch June 30, 2021 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0