Skip to content

Commit

Permalink
[FIX] CBORSerializer now inherits from AbstractIncrementalPacketSeria…
Browse files Browse the repository at this point in the history
…lizer
  • Loading branch information
francis-clairicia committed Nov 3, 2023
1 parent 809df94 commit 5cd8f1d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/easynetwork/serializers/base_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from .._typevars import _DTOPacketT
from ..exceptions import DeserializeError, IncrementalDeserializeError
from ..lowlevel.constants import _DEFAULT_LIMIT
from .abc import AbstractIncrementalPacketSerializer, AbstractPacketSerializer
from .abc import AbstractIncrementalPacketSerializer
from .tools import GeneratorStreamReader


Expand Down Expand Up @@ -241,7 +241,7 @@ def packet_size(self) -> int:
return self.__size


class FileBasedPacketSerializer(AbstractPacketSerializer[_DTOPacketT]):
class FileBasedPacketSerializer(AbstractIncrementalPacketSerializer[_DTOPacketT]):
"""
Base class for APIs requiring a :std:term:`file object` for serialization/deserialization.
"""
Expand Down
10 changes: 10 additions & 0 deletions tests/functional_test/test_serializers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def test____fixture____consistency(
serializer_for_serialization: AbstractPacketSerializer[Any],
serializer_for_deserialization: AbstractPacketSerializer[Any],
) -> None:
assert isinstance(serializer_for_serialization, AbstractPacketSerializer)
assert isinstance(serializer_for_deserialization, AbstractPacketSerializer)
assert type(serializer_for_serialization) is type(serializer_for_deserialization)

def test____slots____no_dict(
Expand Down Expand Up @@ -126,6 +128,14 @@ def invalid_partial_data() -> bytes:
def invalid_partial_data_extra_data() -> bytes | None:
return b"remaining_data"

def test____fixture____consistency____incremental_serializer(
self,
serializer_for_serialization: AbstractIncrementalPacketSerializer[Any],
serializer_for_deserialization: AbstractIncrementalPacketSerializer[Any],
) -> None:
assert isinstance(serializer_for_serialization, AbstractIncrementalPacketSerializer)
assert isinstance(serializer_for_deserialization, AbstractIncrementalPacketSerializer)

def test____incremental_serialize____concatenated_chunks(
self,
serializer_for_serialization: AbstractIncrementalPacketSerializer[Any],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,9 @@ async def test____serve____accept_capacity_error(

# Act
async with AsyncIOTaskGroup() as task_group:
# It retries every 100 ms, so in 950 ms it will retry at 0, 100, ..., 900
# It retries every 100 ms, so in 975 ms it will retry at 0, 100, ..., 900
# = 10 times total
with CancelScope(deadline=asyncio.get_running_loop().time() + 0.950):
with CancelScope(deadline=asyncio.get_running_loop().time() + 0.975):
await listener.serve(handler, task_group)

# Assert
Expand Down

0 comments on commit 5cd8f1d

Please sign in to comment.