tests: Better asserts for better failure messages

(imported from commit 18a485c6edf4c2d7d85098950b29c82c7f5ead42)
This commit is contained in:
Keegan McAllister
2013-01-02 16:07:09 -05:00
parent 15384d473b
commit ec1e16f6be

View File

@@ -86,7 +86,7 @@ class AuthedTestCase(TestCase):
self.assertEquals(json.get("result"), "success") self.assertEquals(json.get("result"), "success")
# We have a msg key for consistency with errors, but it typically has an # We have a msg key for consistency with errors, but it typically has an
# empty value. # empty value.
self.assertTrue("msg" in json) self.assertIn("msg", json)
def assert_json_error(self, result, msg): def assert_json_error(self, result, msg):
""" """
@@ -435,8 +435,8 @@ class SubscriptionPropertiesTest(AuthedTestCase):
subs = gather_subscriptions(self.get_user_profile(test_email)) subs = gather_subscriptions(self.get_user_profile(test_email))
for stream, color in json["stream_colors"]: for stream, color in json["stream_colors"]:
self.assertTrue(isinstance(color, str)) self.assertIsInstance(color, str)
self.assertTrue(isinstance(stream, str)) self.assertIsInstance(stream, str)
self.assertIn((stream, color), subs) self.assertIn((stream, color), subs)
subs.remove((stream, color)) subs.remove((stream, color))
self.assertFalse(subs) self.assertFalse(subs)
@@ -514,7 +514,7 @@ class GetOldMessagesTest(AuthedTestCase):
def check_well_formed_messages_response(self, result): def check_well_formed_messages_response(self, result):
self.assertIn("messages", result) self.assertIn("messages", result)
self.assertTrue(isinstance(result["messages"], list)) self.assertIsInstance(result["messages"], list)
for message in result["messages"]: for message in result["messages"]:
for field in ("content", "content_type", "display_recipient", for field in ("content", "content_type", "display_recipient",
"gravatar_hash", "recipient_id", "sender_full_name", "gravatar_hash", "recipient_id", "sender_full_name",