-
-
Notifications
You must be signed in to change notification settings - Fork 273
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
tests: ui: Add type annotations. #1091
Conversation
import pytest | ||
from pytest_mock import MockerFixture | ||
from urwid import Widget |
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.
I'm not very confident in this being the most relevant type for the widget
parameter in widget_size
, does this fit?
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.
This seems fine for now - it is the base widget class after all?
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.
Yeah, verified by the class's docstring.
53d1aba
to
192f2a8
Compare
This commit assigns patches `stream_box_view` and `private_box_view` using `mocker.patch.object` to maintain type consistency since their mocked nature's assert methods are being called.
This commit uses `mocker.patch.object()` with the `create` argument set as True for attributes of the `View` fixture instance that don't exist without their corresponding generation methods being called. `View`'s `middle_column` is generated by the `middle_column_view()` method and `users_view` is generated by the `right_column_view()` method. Also removes an unused patch.
This commit adds parameter and return type annotations or hints to the `test_ui.py` file, that contains tests for its counterpart `ui.py` from the `zulipterminal` module, to make mypy checks consistent and improve code readability.
This commit adds `test_ui.py` to the `type_consistent_testfiles` list to check for type consistency with mypy.
192f2a8
to
dc2632e
Compare
@prah23 Just amended one commit text to take into account the extra mock removal, and merging now - thanks! 🎉 |
Hello @zulip/server-refactoring members, this pull request was labeled with the "area: refactoring" label, so you may want to check it out! |
What does this PR do?
Adds type annotations to
test_ui.py
and includes it under files to be checked by mypy in the run-mypy tool. Also added a couple of prior commits to use appropriate patches.Tested?
Commit flow
refactor: ui: Patch *_box_views in OPEN_DRAFT tests.
This commit assigns patches
stream_box_view
andprivate_box_view
using
mocker.patch.object
to maintain type consistency since theirmocked nature's assert methods are being called.
refactor: ui: Use patch for non-existent attributes instead of Mock.
This commit uses
mocker.patch
with thecreate
parameter set asTrue for attributes of the
View
fixture instance that don't existwithout their corresponding generation methods being called.
View
'smiddle_column
is generated by themiddle_column_view()
methodand
users_view
is generated by theright_column_view()
method.refactor: tests: ui: Add type annotations.
This commit adds parameter and return type annotations or hints to the
test_ui.py
file, that contains tests for its counterpartui.py
from the
zulipterminal
module, to make mypy checks consistent andimprove code readability.
tools: Include test_ui.py to be checked by mypy.
This commit adds
test_ui.py
to thetype_consistent_testfiles
list to check for type consistency with mypy.