mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix resourcewarnings in websocket tests
This commit is contained in:
parent
60555c1389
commit
08e7cddeb0
@ -165,6 +165,12 @@ class WSClient:
|
|||||||
reason = reason.encode('utf-8')
|
reason = reason.encode('utf-8')
|
||||||
self.write_frame(1, CLOSE, struct.pack(b'!H', code) + reason)
|
self.write_frame(1, CLOSE, struct.pack(b'!H', code) + reason)
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __exit__(self, *a):
|
||||||
|
self.socket.close()
|
||||||
|
|
||||||
|
|
||||||
class WSTestServer(TestServer):
|
class WSTestServer(TestServer):
|
||||||
|
|
||||||
@ -184,7 +190,7 @@ class WSTestServer(TestServer):
|
|||||||
class WebSocketTest(BaseTest):
|
class WebSocketTest(BaseTest):
|
||||||
|
|
||||||
def simple_test(self, server, msgs, expected=(), close_code=NORMAL_CLOSE, send_close=True, close_reason=b'NORMAL CLOSE', ignore_send_failures=False):
|
def simple_test(self, server, msgs, expected=(), close_code=NORMAL_CLOSE, send_close=True, close_reason=b'NORMAL CLOSE', ignore_send_failures=False):
|
||||||
client = server.connect()
|
with server.connect() as client:
|
||||||
for msg in msgs:
|
for msg in msgs:
|
||||||
try:
|
try:
|
||||||
if isinstance(msg, dict):
|
if isinstance(msg, dict):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user