mirror of
https://github.com/zulip/zulip.git
synced 2026-07-15 21:03:26 +08:00
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 <type 'str'>
======================================================================
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 <type 'str'>
----------------------------------------------------------------------
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)
This commit is contained in:
parent
53ec385d0b
commit
cc8ee68514
@ -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:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user