mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 06:53:25 +00:00
tests: Provide more useful output in assert_length().
This commit is contained in:
@@ -450,11 +450,15 @@ class ZulipTestCase(TestCase):
|
|||||||
"""
|
"""
|
||||||
self.assertEqual(self.get_json_error(result, status_code=status_code), msg)
|
self.assertEqual(self.get_json_error(result, status_code=status_code), msg)
|
||||||
|
|
||||||
def assert_length(self, queries, count):
|
def assert_length(self, items, count):
|
||||||
# type: (Sized, int) -> None
|
# type: (List, int) -> None
|
||||||
actual_count = len(queries)
|
actual_count = len(items)
|
||||||
return self.assertTrue(actual_count == count,
|
if actual_count != count: # nocoverage
|
||||||
"len(%s) == %s, != %s" % (queries, actual_count, count))
|
print('ITEMS:\n')
|
||||||
|
for item in items:
|
||||||
|
print(item)
|
||||||
|
print("\nexpected length: %s\nactual length: %s" % (count, actual_count))
|
||||||
|
raise AssertionError('List is unexpected size!')
|
||||||
|
|
||||||
def assert_json_error_contains(self, result, msg_substring, status_code=400):
|
def assert_json_error_contains(self, result, msg_substring, status_code=400):
|
||||||
# type: (HttpResponse, Text, int) -> None
|
# type: (HttpResponse, Text, int) -> None
|
||||||
|
|||||||
Reference in New Issue
Block a user