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