From 22418a2fe084b4f954563b207545f6ce1b608f3b Mon Sep 17 00:00:00 2001 From: M1nd3r Date: Wed, 13 Mar 2024 11:18:37 +0100 Subject: [PATCH] Improve tests --- core/src/storage/cache.py | 3 +-- core/src/trezor/utils.py | 15 +++++---------- core/src/trezor/wire/context.py | 8 ++++---- core/tests/test_storage.cache.py | 6 +----- 4 files changed, 11 insertions(+), 21 deletions(-) diff --git a/core/src/storage/cache.py b/core/src/storage/cache.py index 30fae7ae6..e9bb593ef 100644 --- a/core/src/storage/cache.py +++ b/core/src/storage/cache.py @@ -102,8 +102,7 @@ def delete(key: int) -> None: if TYPE_CHECKING: @overload - def get(key: int) -> bytes | None: - ... + def get(key: int) -> bytes | None: ... @overload def get(key: int, default: T) -> bytes | T: # noqa: F811 diff --git a/core/src/trezor/utils.py b/core/src/trezor/utils.py index 1bf1843e9..7b7f00c18 100644 --- a/core/src/trezor/utils.py +++ b/core/src/trezor/utils.py @@ -148,24 +148,19 @@ def chunks(items: Chunkable, size: int) -> Iterator[Chunkable]: if TYPE_CHECKING: class HashContext(Protocol): - def update(self, __buf: bytes) -> None: - ... + def update(self, __buf: bytes) -> None: ... - def digest(self) -> bytes: - ... + def digest(self) -> bytes: ... class HashContextInitable(HashContext, Protocol): def __init__( # pylint: disable=super-init-not-called self, __data: bytes | None = None - ) -> None: - ... + ) -> None: ... class Writer(Protocol): - def append(self, __b: int) -> None: - ... + def append(self, __b: int) -> None: ... - def extend(self, __buf: bytes) -> None: - ... + def extend(self, __buf: bytes) -> None: ... if False: # noqa diff --git a/core/src/trezor/wire/context.py b/core/src/trezor/wire/context.py index 27f4050d0..5ba9232be 100644 --- a/core/src/trezor/wire/context.py +++ b/core/src/trezor/wire/context.py @@ -78,14 +78,14 @@ class Context: if TYPE_CHECKING: @overload - async def read(self, expected_types: Container[int]) -> protobuf.MessageType: - ... + async def read( + self, expected_types: Container[int] + ) -> protobuf.MessageType: ... @overload async def read( self, expected_types: Container[int], expected_type: type[LoadedMessageType] - ) -> LoadedMessageType: - ... + ) -> LoadedMessageType: ... async def read( self, diff --git a/core/tests/test_storage.cache.py b/core/tests/test_storage.cache.py index b3f13469a..bd9dbbaf0 100644 --- a/core/tests/test_storage.cache.py +++ b/core/tests/test_storage.cache.py @@ -230,13 +230,9 @@ class TestStorageCache(unittest.TestCase): self.assertEqual(cache.get(KEY), b"hello") def test_EndSession(self): -<<<<<<< HEAD - self.assertRaises(cache.InvalidSessionError, cache.get, KEY) - cache.start_session() -======= + self.assertRaises(InvalidSessionError, cache.get, KEY) session_id = cache.start_session() ->>>>>>> 8681ba167 (Basic THP functinality - not-polished prototype) self.assertTrue(is_session_started()) self.assertIsNone(cache.get(KEY)) await_result(handle_EndSession(EndSession()))