Debian Codegraph @

tests/legacy/test_exceptions.py

raw
1 import unittest
2
3 from websockets.datastructures import Headers
4 from websockets.legacy.exceptions import *
5
6
7 class ExceptionsTests(unittest.TestCase):
8 def test_str(self):
9 for exception, exception_str in [
10 (
11 InvalidStatusCode(403, Headers()),
12 "server rejected WebSocket connection: HTTP 403",
13 ),
14 (
15 AbortHandshake(200, Headers(), b"OK\n"),
16 "HTTP 200, 0 headers, 3 bytes",
17 ),
18 (
19 RedirectHandshake("wss://example.com"),
20 "redirect to wss://example.com",
21 ),
22 ]:
23 with self.subTest(exception=exception):
24 self.assertEqual(str(exception), exception_str)