From cc8ee685149afae288f6ae65216a0e1dddb59242 Mon Sep 17 00:00:00 2001 From: Jessica McKellar Date: Thu, 21 Mar 2013 14:19:03 -0400 Subject: [PATCH] tests: assert that text objects are instances of basestring, since they might be str or unicode. This fixes tests that have been failing for me for, well, months, that I've been ignoring: ====================================================================== FAIL: test_successful_subscriptions_list (zephyr.tests.SubscriptionAPITest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/jesstess/dev/humbug/zephyr/tests.py", line 631, in test_successful_subscriptions_list self.assertIsInstance(stream['name'], str) AssertionError: u'Denmark' is not an instance of ====================================================================== FAIL: test_get_stream_colors (zephyr.tests.SubscriptionPropertiesTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/jesstess/dev/humbug/zephyr/tests.py", line 515, in test_get_stream_colors self.assertIsInstance(color, str) AssertionError: u'#c2c2c2' is not an instance of ---------------------------------------------------------------------- The more comprehensive fix to this is going through both our API and JSON calls and ensuring that we always return unicode objects, documenting that, and then testing that more specifically. For now, at least have passing tests. (imported from commit ed1875ea1f66c1f1e89f80502c0d6abb323dc489) --- zephyr/tests.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zephyr/tests.py b/zephyr/tests.py index 120e6e6e08..794e7dcc4f 100644 --- a/zephyr/tests.py +++ b/zephyr/tests.py @@ -585,8 +585,8 @@ class SubscriptionPropertiesTest(AuthedTestCase): subs = gather_subscriptions(self.get_user_profile(test_email)) for stream, color in json["stream_colors"]: - self.assertIsInstance(color, str) - self.assertIsInstance(stream, str) + self.assertIsInstance(color, basestring) + self.assertIsInstance(stream, basestring) self.assertIn({'name': stream, 'in_home_view': True, 'color': color, 'invite_only': False}, subs) subs.remove({'name': stream, 'in_home_view': True, 'color': color, 'invite_only': False}) self.assertFalse(subs) @@ -690,8 +690,8 @@ class SubscriptionAPITest(AuthedTestCase): json = simplejson.loads(result.content) self.assertIn("subscriptions", json) for stream in json["subscriptions"]: - self.assertIsInstance(stream['name'], str) - self.assertIsInstance(stream['color'], str) + self.assertIsInstance(stream['name'], basestring) + self.assertIsInstance(stream['color'], basestring) self.assertIsInstance(stream['invite_only'], bool) # check that the stream name corresponds to an actual stream try: