|
|
|
@ -1095,7 +1095,7 @@ class TestAsyncServer: |
|
|
|
args = {"foo": "bar"} |
|
|
|
s = async_server.AsyncServer(serializer_args=args) |
|
|
|
assert s.packet_class_args == args |
|
|
|
|
|
|
|
|
|
|
|
def test_serializer_args_with_msgpack(self, eio): |
|
|
|
def default(o): |
|
|
|
if isinstance(o, datetime): |
|
|
|
@ -1103,7 +1103,8 @@ class TestAsyncServer: |
|
|
|
raise TypeError("Unknown type") |
|
|
|
args = {"dumps_default": default} |
|
|
|
data = {"current": datetime.now(timezone(timedelta(0)))} |
|
|
|
s = async_server.AsyncServer(serializer='msgpack', serializer_args=args) |
|
|
|
s = async_server.AsyncServer(serializer='msgpack', |
|
|
|
serializer_args=args) |
|
|
|
p = s._create_packet(data=data) |
|
|
|
p2 = s._create_packet(encoded_packet=p.encode()) |
|
|
|
|
|
|
|
@ -1112,9 +1113,10 @@ class TestAsyncServer: |
|
|
|
assert "current" in p2.data |
|
|
|
assert isinstance(p2.data["current"], str) |
|
|
|
assert default(data["current"]) == p2.data["current"] |
|
|
|
|
|
|
|
|
|
|
|
def test_invalid_serializer_args(self, eio): |
|
|
|
args = {"invalid_arg": 123} |
|
|
|
s = async_server.AsyncServer(serializer='msgpack', serializer_args=args) |
|
|
|
s = async_server.AsyncServer(serializer='msgpack', |
|
|
|
serializer_args=args) |
|
|
|
with pytest.raises(TypeError): |
|
|
|
s._create_packet(data={"foo": "bar"}).encode() |
|
|
|
s._create_packet(data={"foo": "bar"}).encode() |
|
|
|
|