diff --git a/channels/test/websocket.py b/channels/test/websocket.py index 4b762ce..c260bd8 100644 --- a/channels/test/websocket.py +++ b/channels/test/websocket.py @@ -82,6 +82,9 @@ class WSClient(Client): self.channel_layer.send(to, self._get_content(content, text, path)) self._session_cookie = False + def _list_headers(self): + return [[key.encode(), self.headers[key]] for key in self.headers] + def _get_content(self, content={}, text=None, path='/'): content = copy.deepcopy(content) content.setdefault('reply_channel', self.reply_channel) @@ -93,7 +96,7 @@ class WSClient(Client): else: content.setdefault('path', path) - content.setdefault('headers', self.headers) + content.setdefault('headers', self._list_headers()) if self._ordered: if 'order' in content: diff --git a/tests/test_wsclient.py b/tests/test_wsclient.py index a8924ca..0b94621 100644 --- a/tests/test_wsclient.py +++ b/tests/test_wsclient.py @@ -52,8 +52,8 @@ class WSClientTests(ChannelTestCase): self.assertEqual(content['path'], '/') self.assertTrue('headers' in content) - self.assertTrue('cookie' in content['headers']) - self.assertTrue(b'sessionid' in content['headers']['cookie']) + self.assertIn(b'cookie', [x[0] for x in content['headers']]) + self.assertIn(b'sessionid', [x[1] for x in content['headers'] if x[0] == b'cookie'][0]) def test_ordering_in_content(self): client = WSClient(ordered=True)