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
Consistently use self.assert_length
in tests.
#18522
Conversation
self.assert_length
in tests.self.assert_length
in tests.
zerver/lib/test_classes.py
Outdated
@@ -864,14 +864,14 @@ def assert_json_error(self, result: HttpResponse, msg: str, status_code: int = 4 | |||
""" | |||
self.assertEqual(self.get_json_error(result, status_code=status_code), msg) | |||
|
|||
def assert_length(self, items: List[Any], count: int) -> None: | |||
def assert_length(self, items: Any, count: int) -> None: |
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 think you want the appropriate abstract base class, Sized
, here.
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.
Probably Collection
, actually, since we do iterate through it.
This looks great aside from the type-checking detail there: We never want to use |
Make it so that `assert_length` can be used for not just lists but all `Collections`. This is prep for using this helper consistently for all tests.
This helper does some nice things like printing out the data structure incase of failure.
a625701
to
5d907ef
Compare
Thanks, fixed to use |
Merged, thanks @abhijeetbodas2001! |
Changes made with Find&Replace with regex.