From 176cd053ab3f1bb478373662479e0000f0309b17 Mon Sep 17 00:00:00 2001 From: Sebastian Majewski Date: Sat, 7 Sep 2024 22:51:38 -0500 Subject: [PATCH] Code cleanup --- ...icmp4__destination_unreachable__asserts.py | 55 ++++++++--------- .../icmp4/test__icmp4__echo_reply__asserts.py | 39 ++++++------ .../test__icmp4__echo_request__asserts.py | 39 ++++++------ .../icmp4/test__icmp4__unknown__asserts.py | 25 ++++---- ...icmp6__destination_unreachable__asserts.py | 29 ++++----- .../icmp6/test__icmp6__echo_reply__asserts.py | 39 ++++++------ .../test__icmp6__echo_request__asserts.py | 39 ++++++------ .../test__icmp6__mld2__report__asserts.py | 21 ++++--- ...p6__nd__neighbor_advertisement__asserts.py | 39 ++++++------ ...mp6__nd__neighbor_solicitation__asserts.py | 27 +++++---- ...cmp6__nd__router_advertisement__asserts.py | 59 ++++++++++--------- ...icmp6__nd__router_solicitation__asserts.py | 23 ++++---- .../icmp6/test__icmp6__unknown__asserts.py | 25 ++++---- 13 files changed, 231 insertions(+), 228 deletions(-) diff --git a/tests/unit/protocols/icmp4/test__icmp4__destination_unreachable__asserts.py b/tests/unit/protocols/icmp4/test__icmp4__destination_unreachable__asserts.py index 2ac0091e..effd75ff 100644 --- a/tests/unit/protocols/icmp4/test__icmp4__destination_unreachable__asserts.py +++ b/tests/unit/protocols/icmp4/test__icmp4__destination_unreachable__asserts.py @@ -34,6 +34,8 @@ """ +from typing import Any + from testslide import TestCase from pytcp.lib.int_checks import UINT_16__MAX, UINT_16__MIN @@ -57,7 +59,8 @@ def setUp(self) -> None: message constructor. """ - self._message_kwargs = { + self._args: list[Any] = [] + self._kwargs: dict[str, Any] = { "code": Icmp4DestinationUnreachableCode.NETWORK, "mtu": None, "cksum": 0, @@ -73,10 +76,10 @@ def test__icmp4__destination_unreachable__code__not_Icmp4DestinationUnreachableC an Icmp4DestinationUnreachableCode. """ - self._message_kwargs["code"] = value = "not an Icmp4DestinationUnreachableCode" # type: ignore + self._kwargs["code"] = value = "not an Icmp4DestinationUnreachableCode" with self.assertRaises(AssertionError) as error: - Icmp4DestinationUnreachableMessage(**self._message_kwargs) # type: ignore + Icmp4DestinationUnreachableMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -94,15 +97,13 @@ def test__icmp4__destination_unreachable__frag_no_mtu( provided. """ - self._message_kwargs["code"] = ( + self._kwargs["code"] = ( Icmp4DestinationUnreachableCode.FRAGMENTATION_NEEDED ) - self._message_kwargs["mtu"] = value = None + self._kwargs["mtu"] = value = None with self.assertRaises(AssertionError) as error: - Icmp4DestinationUnreachableMessage( - **self._message_kwargs, # type: ignore - ) + Icmp4DestinationUnreachableMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -120,13 +121,13 @@ def test__icmp4__destination_unreachable__no_frag_mtu( provided. """ - self._message_kwargs["mtu"] = value = 1500 + self._kwargs["mtu"] = value = 1500 for code in Icmp4DestinationUnreachableCode: if code != Icmp4DestinationUnreachableCode.FRAGMENTATION_NEEDED: with self.assertRaises(AssertionError) as error: Icmp4DestinationUnreachableMessage( - **self._message_kwargs, # type: ignore + *self._args, **self._kwargs ) self.assertEqual( @@ -143,12 +144,10 @@ def test__icmp4__destination_unreachable__cksum__under_min( is lower than the minimum supported value. """ - self._message_kwargs["cksum"] = value = UINT_16__MIN - 1 + self._kwargs["cksum"] = value = UINT_16__MIN - 1 with self.assertRaises(AssertionError) as error: - Icmp4DestinationUnreachableMessage( - **self._message_kwargs, # type: ignore - ) + Icmp4DestinationUnreachableMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -165,12 +164,10 @@ def test__icmp4__destination_unreachable__cksum__over_max( is higher than the maximum supported value. """ - self._message_kwargs["cksum"] = value = UINT_16__MAX + 1 + self._kwargs["cksum"] = value = UINT_16__MAX + 1 with self.assertRaises(AssertionError) as error: - Icmp4DestinationUnreachableMessage( - **self._message_kwargs, # type: ignore - ) + Icmp4DestinationUnreachableMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -187,15 +184,13 @@ def test__icmp4__destination_unreachable__mtu__under_min( is lower than the minimum supported value. """ - self._message_kwargs["code"] = ( + self._kwargs["code"] = ( Icmp4DestinationUnreachableCode.FRAGMENTATION_NEEDED ) - self._message_kwargs["mtu"] = value = UINT_16__MIN - 1 + self._kwargs["mtu"] = value = UINT_16__MIN - 1 with self.assertRaises(AssertionError) as error: - Icmp4DestinationUnreachableMessage( - **self._message_kwargs, # type: ignore - ) + Icmp4DestinationUnreachableMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -212,15 +207,13 @@ def test__icmp4__destination_unreachable__mtu__over_max( is higher than the maximum supported value. """ - self._message_kwargs["code"] = ( + self._kwargs["code"] = ( Icmp4DestinationUnreachableCode.FRAGMENTATION_NEEDED ) - self._message_kwargs["mtu"] = value = UINT_16__MAX + 1 + self._kwargs["mtu"] = value = UINT_16__MAX + 1 with self.assertRaises(AssertionError) as error: - Icmp4DestinationUnreachableMessage( - **self._message_kwargs, # type: ignore - ) + Icmp4DestinationUnreachableMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -238,12 +231,10 @@ def test__icmp4__destination_unreachable__data_len__over_max( """ value = IP4__PAYLOAD__MAX_LEN - ICMP4__DESTINATION_UNREACHABLE__LEN + 1 - self._message_kwargs["data"] = b"X" * value + self._kwargs["data"] = b"X" * value with self.assertRaises(AssertionError) as error: - Icmp4DestinationUnreachableMessage( - **self._message_kwargs, # type: ignore - ) + Icmp4DestinationUnreachableMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), diff --git a/tests/unit/protocols/icmp4/test__icmp4__echo_reply__asserts.py b/tests/unit/protocols/icmp4/test__icmp4__echo_reply__asserts.py index 48d20bb6..2d081792 100644 --- a/tests/unit/protocols/icmp4/test__icmp4__echo_reply__asserts.py +++ b/tests/unit/protocols/icmp4/test__icmp4__echo_reply__asserts.py @@ -34,6 +34,8 @@ """ +from typing import Any + from testslide import TestCase from pytcp.lib.int_checks import UINT_16__MAX, UINT_16__MIN @@ -57,7 +59,8 @@ def setUp(self) -> None: constructor. """ - self._message_kwargs = { + self._args: list[Any] = [] + self._kwargs: dict[str, Any] = { "code": Icmp4EchoReplyCode.DEFAULT, "cksum": 0, "id": 0, @@ -73,10 +76,10 @@ def test__icmp4__echo_reply__code__not_Icmp4EchoReplyCode( when the provided 'code' argument is not an Icmp4EchoReplyCode. """ - self._message_kwargs["code"] = value = "not an Icmp4EchoReplyCode" + self._kwargs["code"] = value = "not an Icmp4EchoReplyCode" with self.assertRaises(AssertionError) as error: - Icmp4EchoReplyMessage(**self._message_kwargs) # type: ignore + Icmp4EchoReplyMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -91,10 +94,10 @@ def test__icmp4__echo_reply__cksum__under_min(self) -> None: minimum supported value. """ - self._message_kwargs["cksum"] = value = UINT_16__MIN - 1 + self._kwargs["cksum"] = value = UINT_16__MIN - 1 with self.assertRaises(AssertionError) as error: - Icmp4EchoReplyMessage(**self._message_kwargs) # type: ignore + Icmp4EchoReplyMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -109,10 +112,10 @@ def test__icmp4__echo_reply__cksum__over_max(self) -> None: maximum supported value. """ - self._message_kwargs["cksum"] = value = UINT_16__MAX + 1 + self._kwargs["cksum"] = value = UINT_16__MAX + 1 with self.assertRaises(AssertionError) as error: - Icmp4EchoReplyMessage(**self._message_kwargs) # type: ignore + Icmp4EchoReplyMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -127,10 +130,10 @@ def test__icmp4__echo_reply__id__under_min(self) -> None: minimum supported value. """ - self._message_kwargs["id"] = value = UINT_16__MIN - 1 + self._kwargs["id"] = value = UINT_16__MIN - 1 with self.assertRaises(AssertionError) as error: - Icmp4EchoReplyMessage(**self._message_kwargs) # type: ignore + Icmp4EchoReplyMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -145,10 +148,10 @@ def test__icmp4__echo_reply__id__over_max(self) -> None: maximum supported value. """ - self._message_kwargs["id"] = value = UINT_16__MAX + 1 + self._kwargs["id"] = value = UINT_16__MAX + 1 with self.assertRaises(AssertionError) as error: - Icmp4EchoReplyMessage(**self._message_kwargs) # type: ignore + Icmp4EchoReplyMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -163,10 +166,10 @@ def test__icmp4__echo_reply__seq__under_min(self) -> None: minimum supported value. """ - self._message_kwargs["seq"] = value = UINT_16__MIN - 1 + self._kwargs["seq"] = value = UINT_16__MIN - 1 with self.assertRaises(AssertionError) as error: - Icmp4EchoReplyMessage(**self._message_kwargs) # type: ignore + Icmp4EchoReplyMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -181,10 +184,10 @@ def test__icmp4__echo_reply__seq__over_max(self) -> None: maximum supported value. """ - self._message_kwargs["seq"] = value = UINT_16__MAX + 1 + self._kwargs["seq"] = value = UINT_16__MAX + 1 with self.assertRaises(AssertionError) as error: - Icmp4EchoReplyMessage(**self._message_kwargs) # type: ignore + Icmp4EchoReplyMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -200,12 +203,10 @@ def test__icmp4__echo_reply__data_len__over_max(self) -> None: """ value = IP4__PAYLOAD__MAX_LEN - ICMP4__ECHO_REPLY__LEN + 1 - self._message_kwargs["data"] = b"X" * value + self._kwargs["data"] = b"X" * value with self.assertRaises(AssertionError) as error: - Icmp4EchoReplyMessage( - **self._message_kwargs, # type: ignore - ) + Icmp4EchoReplyMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), diff --git a/tests/unit/protocols/icmp4/test__icmp4__echo_request__asserts.py b/tests/unit/protocols/icmp4/test__icmp4__echo_request__asserts.py index ceac3e5c..e6e14a43 100644 --- a/tests/unit/protocols/icmp4/test__icmp4__echo_request__asserts.py +++ b/tests/unit/protocols/icmp4/test__icmp4__echo_request__asserts.py @@ -34,6 +34,8 @@ """ +from typing import Any + from testslide import TestCase from pytcp.lib.int_checks import UINT_16__MAX, UINT_16__MIN @@ -57,7 +59,8 @@ def setUp(self) -> None: constructor. """ - self._message_kwargs = { + self._args: list[Any] = [] + self._kwargs: dict[str, Any] = { "code": Icmp4EchoRequestCode.DEFAULT, "cksum": 0, "id": 0, @@ -73,10 +76,10 @@ def test__icmp4__echo_request__code__not_Icmp4EchoRequestCode( when the provided 'code' argument is not an Icmp4EchoRequestCode. """ - self._message_kwargs["code"] = value = "not an Icmp4EchoRequestCode" + self._kwargs["code"] = value = "not an Icmp4EchoRequestCode" with self.assertRaises(AssertionError) as error: - Icmp4EchoRequestMessage(**self._message_kwargs) # type: ignore + Icmp4EchoRequestMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -91,10 +94,10 @@ def test__icmp4__echo_request__cksum__under_min(self) -> None: minimum supported value. """ - self._message_kwargs["cksum"] = value = UINT_16__MIN - 1 + self._kwargs["cksum"] = value = UINT_16__MIN - 1 with self.assertRaises(AssertionError) as error: - Icmp4EchoRequestMessage(**self._message_kwargs) # type: ignore + Icmp4EchoRequestMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -109,10 +112,10 @@ def test__icmp4__echo_request__cksum__over_max(self) -> None: maximum supported value. """ - self._message_kwargs["cksum"] = value = UINT_16__MAX + 1 + self._kwargs["cksum"] = value = UINT_16__MAX + 1 with self.assertRaises(AssertionError) as error: - Icmp4EchoRequestMessage(**self._message_kwargs) # type: ignore + Icmp4EchoRequestMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -127,10 +130,10 @@ def test__icmp4__echo_request__id__under_min(self) -> None: minimum supported value. """ - self._message_kwargs["id"] = value = UINT_16__MIN - 1 + self._kwargs["id"] = value = UINT_16__MIN - 1 with self.assertRaises(AssertionError) as error: - Icmp4EchoRequestMessage(**self._message_kwargs) # type: ignore + Icmp4EchoRequestMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -145,10 +148,10 @@ def test__icmp4__echo_request__id__over_max(self) -> None: maximum supported value. """ - self._message_kwargs["id"] = value = UINT_16__MAX + 1 + self._kwargs["id"] = value = UINT_16__MAX + 1 with self.assertRaises(AssertionError) as error: - Icmp4EchoRequestMessage(**self._message_kwargs) # type: ignore + Icmp4EchoRequestMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -163,10 +166,10 @@ def test__icmp4__echo_request__seq__under_min(self) -> None: minimum supported value. """ - self._message_kwargs["seq"] = value = UINT_16__MIN - 1 + self._kwargs["seq"] = value = UINT_16__MIN - 1 with self.assertRaises(AssertionError) as error: - Icmp4EchoRequestMessage(**self._message_kwargs) # type: ignore + Icmp4EchoRequestMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -181,10 +184,10 @@ def test__icmp4__echo_request__seq__over_max(self) -> None: maximum supported value. """ - self._message_kwargs["seq"] = value = UINT_16__MAX + 1 + self._kwargs["seq"] = value = UINT_16__MAX + 1 with self.assertRaises(AssertionError) as error: - Icmp4EchoRequestMessage(**self._message_kwargs) # type: ignore + Icmp4EchoRequestMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -200,12 +203,10 @@ def test__icmp4__echo_request__data_len__over_max(self) -> None: """ value = IP4__PAYLOAD__MAX_LEN - ICMP4__ECHO_REQUEST__LEN + 1 - self._message_kwargs["data"] = b"X" * value + self._kwargs["data"] = b"X" * value with self.assertRaises(AssertionError) as error: - Icmp4EchoRequestMessage( - **self._message_kwargs, # type: ignore - ) + Icmp4EchoRequestMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), diff --git a/tests/unit/protocols/icmp4/test__icmp4__unknown__asserts.py b/tests/unit/protocols/icmp4/test__icmp4__unknown__asserts.py index ebdca0a6..cbbaa270 100644 --- a/tests/unit/protocols/icmp4/test__icmp4__unknown__asserts.py +++ b/tests/unit/protocols/icmp4/test__icmp4__unknown__asserts.py @@ -33,6 +33,8 @@ """ +from typing import Any + from testslide import TestCase from pytcp.lib.inet_cksum import inet_cksum @@ -54,7 +56,8 @@ def setUp(self) -> None: constructor. """ - self._message_kwargs = { + self._args: list[Any] = [] + self._kwargs: dict[str, Any] = { "type": Icmp4Type.from_int(255), "code": Icmp4Code.from_int(255), "cksum": 0, @@ -67,10 +70,10 @@ def test__icmp4__unknown__type__not_Icmp4Type(self) -> None: when the provided 'type' argument is not an Icmp4Type. """ - self._message_kwargs["type"] = value = "not an Icmp4Type" + self._kwargs["type"] = value = "not an Icmp4Type" with self.assertRaises(AssertionError) as error: - Icmp4UnknownMessage(**self._message_kwargs) # type: ignore + Icmp4UnknownMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -83,10 +86,10 @@ def test__icmp4__unknown__code__not_Icmp4Code(self) -> None: when the provided 'code' argument is not an Icmp4Code. """ - self._message_kwargs["code"] = value = "not an Icmp4Code" + self._kwargs["code"] = value = "not an Icmp4Code" with self.assertRaises(AssertionError) as error: - Icmp4UnknownMessage(**self._message_kwargs) # type: ignore + Icmp4UnknownMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -100,10 +103,10 @@ def test__icmp4__echo_request__cksum__under_min(self) -> None: the minimum supported value. """ - self._message_kwargs["cksum"] = value = UINT_16__MIN - 1 + self._kwargs["cksum"] = value = UINT_16__MIN - 1 with self.assertRaises(AssertionError) as error: - Icmp4UnknownMessage(**self._message_kwargs) # type: ignore + Icmp4UnknownMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -118,10 +121,10 @@ def test__icmp4__echo_request__cksum__over_max(self) -> None: the maximum supported value. """ - self._message_kwargs["cksum"] = value = UINT_16__MAX + 1 + self._kwargs["cksum"] = value = UINT_16__MAX + 1 with self.assertRaises(AssertionError) as error: - Icmp4UnknownMessage(**self._message_kwargs) # type: ignore + Icmp4UnknownMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -135,10 +138,10 @@ def test__icmp4__unknown__raw__not_bytes(self) -> None: when the provided 'raw' argument is not bytes. """ - self._message_kwargs["raw"] = value = "not bytes or memoryview" + self._kwargs["raw"] = value = "not bytes or memoryview" with self.assertRaises(AssertionError) as error: - Icmp4UnknownMessage(**self._message_kwargs) # type: ignore + Icmp4UnknownMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), diff --git a/tests/unit/protocols/icmp6/test__icmp6__destination_unreachable__asserts.py b/tests/unit/protocols/icmp6/test__icmp6__destination_unreachable__asserts.py index 0d3e9b0f..1630caa9 100644 --- a/tests/unit/protocols/icmp6/test__icmp6__destination_unreachable__asserts.py +++ b/tests/unit/protocols/icmp6/test__icmp6__destination_unreachable__asserts.py @@ -34,6 +34,8 @@ """ +from typing import Any + from testslide import TestCase from pytcp.lib.int_checks import UINT_16__MAX, UINT_16__MIN @@ -57,7 +59,8 @@ def setUp(self) -> None: message constructor. """ - self._message_kwargs = { + self._args: list[Any] = [] + self._kwargs: dict[str, Any] = { "code": Icmp6DestinationUnreachableCode.NO_ROUTE, "cksum": 0, "data": b"", @@ -71,12 +74,10 @@ def test__icmp6__destination_unreachable__code__not_Icmp6DestinationUnreachableC when the provided 'code' argument is not an Icmp6DestinationUnreachableCode. """ - self._message_kwargs["code"] = value = ( - "not an Icmp6DestinationUnreachableCode" - ) + self._kwargs["code"] = value = "not an Icmp6DestinationUnreachableCode" with self.assertRaises(AssertionError) as error: - Icmp6DestinationUnreachableMessage(**self._message_kwargs) # type: ignore + Icmp6DestinationUnreachableMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -93,12 +94,10 @@ def test__icmp6__destination_unreachable__cksum__under_min( is lower than the minimum supported value. """ - self._message_kwargs["cksum"] = value = UINT_16__MIN - 1 + self._kwargs["cksum"] = value = UINT_16__MIN - 1 with self.assertRaises(AssertionError) as error: - Icmp6DestinationUnreachableMessage( - **self._message_kwargs, # type: ignore - ) + Icmp6DestinationUnreachableMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -114,12 +113,10 @@ def test__icmp6__destination_unreachable__cksum__over_max( is higher than the maximum supported value. """ - self._message_kwargs["cksum"] = value = UINT_16__MAX + 1 + self._kwargs["cksum"] = value = UINT_16__MAX + 1 with self.assertRaises(AssertionError) as error: - Icmp6DestinationUnreachableMessage( - **self._message_kwargs, # type: ignore - ) + Icmp6DestinationUnreachableMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -136,12 +133,10 @@ def test__icmp6__destination_unreachable__data_len__over_max( """ value = IP6__PAYLOAD__MAX_LEN - ICMP6__DESTINATION_UNREACHABLE__LEN + 1 - self._message_kwargs["data"] = b"X" * value + self._kwargs["data"] = b"X" * value with self.assertRaises(AssertionError) as error: - Icmp6DestinationUnreachableMessage( - **self._message_kwargs, # type: ignore - ) + Icmp6DestinationUnreachableMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), diff --git a/tests/unit/protocols/icmp6/test__icmp6__echo_reply__asserts.py b/tests/unit/protocols/icmp6/test__icmp6__echo_reply__asserts.py index c1aad3b9..a5fea12b 100644 --- a/tests/unit/protocols/icmp6/test__icmp6__echo_reply__asserts.py +++ b/tests/unit/protocols/icmp6/test__icmp6__echo_reply__asserts.py @@ -33,6 +33,8 @@ ver 3.0.2 """ +from typing import Any + from testslide import TestCase from pytcp.lib.int_checks import UINT_16__MAX, UINT_16__MIN @@ -55,7 +57,8 @@ def setUp(self) -> None: constructor. """ - self._message_kwargs = { + self._args: list[Any] = [] + self._kwargs: dict[str, Any] = { "code": Icmp6EchoReplyCode.DEFAULT, "cksum": 0, "id": 0, @@ -71,10 +74,10 @@ def test__icmp6__echo_reply__code__not_Icmp6EchoReplyCode( when the provided 'code' argument is not an Icmp6EchoReplyCode. """ - self._message_kwargs["code"] = value = "not an Icmp6EchoReplyCode" + self._kwargs["code"] = value = "not an Icmp6EchoReplyCode" with self.assertRaises(AssertionError) as error: - Icmp6EchoReplyMessage(**self._message_kwargs) # type: ignore + Icmp6EchoReplyMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -91,10 +94,10 @@ def test__icmp6__echo_reply__cksum__under_min(self) -> None: minimum supported value. """ - self._message_kwargs["cksum"] = value = UINT_16__MIN - 1 + self._kwargs["cksum"] = value = UINT_16__MIN - 1 with self.assertRaises(AssertionError) as error: - Icmp6EchoReplyMessage(**self._message_kwargs) # type: ignore + Icmp6EchoReplyMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -111,10 +114,10 @@ def test__icmp6__echo_reply__cksum__over_max(self) -> None: maximum supported value. """ - self._message_kwargs["cksum"] = value = UINT_16__MAX + 1 + self._kwargs["cksum"] = value = UINT_16__MAX + 1 with self.assertRaises(AssertionError) as error: - Icmp6EchoReplyMessage(**self._message_kwargs) # type: ignore + Icmp6EchoReplyMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -131,10 +134,10 @@ def test__icmp6__echo_reply__id__under_min(self) -> None: minimum supported value. """ - self._message_kwargs["id"] = value = UINT_16__MIN - 1 + self._kwargs["id"] = value = UINT_16__MIN - 1 with self.assertRaises(AssertionError) as error: - Icmp6EchoReplyMessage(**self._message_kwargs) # type: ignore + Icmp6EchoReplyMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -151,10 +154,10 @@ def test__icmp6__echo_reply__id__over_max(self) -> None: maximum supported value. """ - self._message_kwargs["id"] = value = UINT_16__MAX + 1 + self._kwargs["id"] = value = UINT_16__MAX + 1 with self.assertRaises(AssertionError) as error: - Icmp6EchoReplyMessage(**self._message_kwargs) # type: ignore + Icmp6EchoReplyMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -171,10 +174,10 @@ def test__icmp6__echo_reply__seq__under_min(self) -> None: minimum supported value. """ - self._message_kwargs["seq"] = value = UINT_16__MIN - 1 + self._kwargs["seq"] = value = UINT_16__MIN - 1 with self.assertRaises(AssertionError) as error: - Icmp6EchoReplyMessage(**self._message_kwargs) # type: ignore + Icmp6EchoReplyMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -191,10 +194,10 @@ def test__icmp6__echo_reply__seq__over_max(self) -> None: maximum supported value. """ - self._message_kwargs["seq"] = value = UINT_16__MAX + 1 + self._kwargs["seq"] = value = UINT_16__MAX + 1 with self.assertRaises(AssertionError) as error: - Icmp6EchoReplyMessage(**self._message_kwargs) # type: ignore + Icmp6EchoReplyMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -212,12 +215,10 @@ def test__icmp6__echo_reply__data_len__over_max(self) -> None: """ value = IP6__PAYLOAD__MAX_LEN - ICMP6__ECHO_REPLY__LEN + 1 - self._message_kwargs["data"] = b"X" * value + self._kwargs["data"] = b"X" * value with self.assertRaises(AssertionError) as error: - Icmp6EchoReplyMessage( - **self._message_kwargs, # type: ignore - ) + Icmp6EchoReplyMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), diff --git a/tests/unit/protocols/icmp6/test__icmp6__echo_request__asserts.py b/tests/unit/protocols/icmp6/test__icmp6__echo_request__asserts.py index 0816f547..696fa4e3 100644 --- a/tests/unit/protocols/icmp6/test__icmp6__echo_request__asserts.py +++ b/tests/unit/protocols/icmp6/test__icmp6__echo_request__asserts.py @@ -33,6 +33,8 @@ ver 3.0.2 """ +from typing import Any + from testslide import TestCase from pytcp.lib.int_checks import UINT_16__MAX, UINT_16__MIN @@ -55,7 +57,8 @@ def setUp(self) -> None: constructor. """ - self._message_kwargs = { + self._args: list[Any] = [] + self._kwargs: dict[str, Any] = { "code": Icmp6EchoRequestCode.DEFAULT, "cksum": 0, "id": 0, @@ -71,10 +74,10 @@ def test__icmp6__echo_request__code__not_Icmp6EchoRequestCode( when the provided 'code' argument is not an Icmp6EchoRequestCode. """ - self._message_kwargs["code"] = value = "not an Icmp6EchoRequestCode" + self._kwargs["code"] = value = "not an Icmp6EchoRequestCode" with self.assertRaises(AssertionError) as error: - Icmp6EchoRequestMessage(**self._message_kwargs) # type: ignore + Icmp6EchoRequestMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -89,10 +92,10 @@ def test__icmp6__echo_request__cksum__under_min(self) -> None: minimum supported value. """ - self._message_kwargs["cksum"] = value = UINT_16__MIN - 1 + self._kwargs["cksum"] = value = UINT_16__MIN - 1 with self.assertRaises(AssertionError) as error: - Icmp6EchoRequestMessage(**self._message_kwargs) # type: ignore + Icmp6EchoRequestMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -107,10 +110,10 @@ def test__icmp6__echo_request__cksum__over_max(self) -> None: maximum supported value. """ - self._message_kwargs["cksum"] = value = UINT_16__MAX + 1 + self._kwargs["cksum"] = value = UINT_16__MAX + 1 with self.assertRaises(AssertionError) as error: - Icmp6EchoRequestMessage(**self._message_kwargs) # type: ignore + Icmp6EchoRequestMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -125,10 +128,10 @@ def test__icmp6__echo_request__id__under_min(self) -> None: minimum supported value. """ - self._message_kwargs["id"] = value = UINT_16__MIN - 1 + self._kwargs["id"] = value = UINT_16__MIN - 1 with self.assertRaises(AssertionError) as error: - Icmp6EchoRequestMessage(**self._message_kwargs) # type: ignore + Icmp6EchoRequestMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -143,10 +146,10 @@ def test__icmp6__echo_request__id__over_max(self) -> None: maximum supported value. """ - self._message_kwargs["id"] = value = UINT_16__MAX + 1 + self._kwargs["id"] = value = UINT_16__MAX + 1 with self.assertRaises(AssertionError) as error: - Icmp6EchoRequestMessage(**self._message_kwargs) # type: ignore + Icmp6EchoRequestMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -161,10 +164,10 @@ def test__icmp6__echo_request__seq__under_min(self) -> None: minimum supported value. """ - self._message_kwargs["seq"] = value = UINT_16__MIN - 1 + self._kwargs["seq"] = value = UINT_16__MIN - 1 with self.assertRaises(AssertionError) as error: - Icmp6EchoRequestMessage(**self._message_kwargs) # type: ignore + Icmp6EchoRequestMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -179,10 +182,10 @@ def test__icmp6__echo_request__seq__over_max(self) -> None: maximum supported value. """ - self._message_kwargs["seq"] = value = UINT_16__MAX + 1 + self._kwargs["seq"] = value = UINT_16__MAX + 1 with self.assertRaises(AssertionError) as error: - Icmp6EchoRequestMessage(**self._message_kwargs) # type: ignore + Icmp6EchoRequestMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -198,12 +201,10 @@ def test__icmp6__echo_request__data_len__over_max(self) -> None: """ value = IP6__PAYLOAD__MAX_LEN - ICMP6__ECHO_REQUEST__LEN + 1 - self._message_kwargs["data"] = b"X" * value + self._kwargs["data"] = b"X" * value with self.assertRaises(AssertionError) as error: - Icmp6EchoRequestMessage( - **self._message_kwargs, # type: ignore - ) + Icmp6EchoRequestMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), diff --git a/tests/unit/protocols/icmp6/test__icmp6__mld2__report__asserts.py b/tests/unit/protocols/icmp6/test__icmp6__mld2__report__asserts.py index 8ef53afe..f7834521 100644 --- a/tests/unit/protocols/icmp6/test__icmp6__mld2__report__asserts.py +++ b/tests/unit/protocols/icmp6/test__icmp6__mld2__report__asserts.py @@ -33,6 +33,8 @@ ver 3.0.2 """ +from typing import Any + from testslide import TestCase from pytcp.lib.int_checks import UINT_16__MAX, UINT_16__MIN @@ -61,7 +63,8 @@ def setUp(self) -> None: constructor. """ - self._message_kwargs = { + self._args: list[Any] = [] + self._kwargs: dict[str, Any] = { "code": Icmp6Mld2ReportCode.DEFAULT, "cksum": 0, "records": [], @@ -75,10 +78,10 @@ def test__icmp6__mld2_report__code__not_Icmp6Mld2ReportCode( when the provided 'code' argument is not an Icmp6EchoRequestCode. """ - self._message_kwargs["code"] = value = "not an Icmp6Mld2ReportCode" + self._kwargs["code"] = value = "not an Icmp6Mld2ReportCode" with self.assertRaises(AssertionError) as error: - Icmp6Mld2ReportMessage(**self._message_kwargs) # type: ignore + Icmp6Mld2ReportMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -95,10 +98,10 @@ def test__icmp6__mld2__report__cksum__under_min(self) -> None: minimum supported value. """ - self._message_kwargs["cksum"] = value = UINT_16__MIN - 1 + self._kwargs["cksum"] = value = UINT_16__MIN - 1 with self.assertRaises(AssertionError) as error: - Icmp6Mld2ReportMessage(**self._message_kwargs) # type: ignore + Icmp6Mld2ReportMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -115,10 +118,10 @@ def test__icmp6__mld2__report__cksum__over_max(self) -> None: maximum supported value. """ - self._message_kwargs["cksum"] = value = UINT_16__MAX + 1 + self._kwargs["cksum"] = value = UINT_16__MAX + 1 with self.assertRaises(AssertionError) as error: - Icmp6Mld2ReportMessage(**self._message_kwargs) # type: ignore + Icmp6Mld2ReportMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -148,10 +151,10 @@ def test__icmp6__message__mld2__report__records_len__over_max(self) -> None: ), ) - self._message_kwargs["records"] = [multicast_address_report] + self._kwargs["records"] = [multicast_address_report] with self.assertRaises(AssertionError) as error: - Icmp6Mld2ReportMessage(**self._message_kwargs) # type: ignore + Icmp6Mld2ReportMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), diff --git a/tests/unit/protocols/icmp6/test__icmp6__nd__neighbor_advertisement__asserts.py b/tests/unit/protocols/icmp6/test__icmp6__nd__neighbor_advertisement__asserts.py index 619d4beb..535c7372 100644 --- a/tests/unit/protocols/icmp6/test__icmp6__nd__neighbor_advertisement__asserts.py +++ b/tests/unit/protocols/icmp6/test__icmp6__nd__neighbor_advertisement__asserts.py @@ -33,6 +33,8 @@ ver 3.0.2 """ +from typing import Any + from testslide import TestCase from pytcp.lib.int_checks import UINT_16__MAX, UINT_16__MIN @@ -58,7 +60,8 @@ def setUp(self) -> None: message constructor. """ - self._message_kwargs = { + self._args: list[Any] = [] + self._kwargs: dict[str, Any] = { "code": Icmp6NdNeighborAdvertisementCode.DEFAULT, "cksum": 0, "target_address": Ip6Address(), @@ -73,12 +76,10 @@ def test__icmp6__nd__neighbor_advertisement__code__not_Icmp6NdNeighborAdvertisem provided 'code' argument is not an Icmp6NdNeighborAdvertisementCode. """ - self._message_kwargs["code"] = value = ( - "not an Icmp6NdNeighborAdvertisementCode" - ) + self._kwargs["code"] = value = "not an Icmp6NdNeighborAdvertisementCode" with self.assertRaises(AssertionError) as error: - Icmp6NdNeighborAdvertisementMessage(**self._message_kwargs) # type: ignore + Icmp6NdNeighborAdvertisementMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -97,10 +98,10 @@ def test__icmp6__nd__neighbor_advertisement__cksum__under_min( the minimum supported value. """ - self._message_kwargs["cksum"] = value = UINT_16__MIN - 1 + self._kwargs["cksum"] = value = UINT_16__MIN - 1 with self.assertRaises(AssertionError) as error: - Icmp6NdNeighborAdvertisementMessage(**self._message_kwargs) # type: ignore + Icmp6NdNeighborAdvertisementMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -119,10 +120,10 @@ def test__icmp6__nd__neighbor_advertisement__cksum__over_max( the maximum supported value. """ - self._message_kwargs["cksum"] = value = UINT_16__MAX + 1 + self._kwargs["cksum"] = value = UINT_16__MAX + 1 with self.assertRaises(AssertionError) as error: - Icmp6NdNeighborAdvertisementMessage(**self._message_kwargs) # type: ignore + Icmp6NdNeighborAdvertisementMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -140,10 +141,10 @@ def test__icmp6__nd__neighbor_advertisement__flag_r__not_boolean( the provided 'flag_r' argument is not an Ip6Address. """ - self._message_kwargs["flag_r"] = value = "not an boolean" + self._kwargs["flag_r"] = value = "not an boolean" with self.assertRaises(AssertionError) as error: - Icmp6NdNeighborAdvertisementMessage(**self._message_kwargs) # type: ignore + Icmp6NdNeighborAdvertisementMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -158,10 +159,10 @@ def test__icmp6__nd__neighbor_advertisement__flag_s__not_boolean( the provided 'flag_s' argument is not an Ip6Address. """ - self._message_kwargs["flag_s"] = value = "not an boolean" + self._kwargs["flag_s"] = value = "not an boolean" with self.assertRaises(AssertionError) as error: - Icmp6NdNeighborAdvertisementMessage(**self._message_kwargs) # type: ignore + Icmp6NdNeighborAdvertisementMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -176,10 +177,10 @@ def test__icmp6__nd__neighbor_advertisement__flag_o__not_boolean( the provided 'flag_o' argument is not an Ip6Address. """ - self._message_kwargs["flag_o"] = value = "not an boolean" + self._kwargs["flag_o"] = value = "not an boolean" with self.assertRaises(AssertionError) as error: - Icmp6NdNeighborAdvertisementMessage(**self._message_kwargs) # type: ignore + Icmp6NdNeighborAdvertisementMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -194,10 +195,10 @@ def test__icmp6__nd__neighbor_advertisement__target_address__not_Ip6Address( the provided 'target_address' argument is not an Ip6Address. """ - self._message_kwargs["target_address"] = value = "not an Ip6Address" + self._kwargs["target_address"] = value = "not an Ip6Address" with self.assertRaises(AssertionError) as error: - Icmp6NdNeighborAdvertisementMessage(**self._message_kwargs) # type: ignore + Icmp6NdNeighborAdvertisementMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -215,10 +216,10 @@ def test__icmp6__nd__neighbor_advertisement__options__not_Icmp6NdOptions( the provided 'options' argument is not an Icmp6NdOptions. """ - self._message_kwargs["options"] = value = "not an Icmp6NdOptions" + self._kwargs["options"] = value = "not an Icmp6NdOptions" with self.assertRaises(AssertionError) as error: - Icmp6NdNeighborAdvertisementMessage(**self._message_kwargs) # type: ignore + Icmp6NdNeighborAdvertisementMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), diff --git a/tests/unit/protocols/icmp6/test__icmp6__nd__neighbor_solicitation__asserts.py b/tests/unit/protocols/icmp6/test__icmp6__nd__neighbor_solicitation__asserts.py index 51bde7a9..ce0a433c 100644 --- a/tests/unit/protocols/icmp6/test__icmp6__nd__neighbor_solicitation__asserts.py +++ b/tests/unit/protocols/icmp6/test__icmp6__nd__neighbor_solicitation__asserts.py @@ -33,6 +33,8 @@ ver 3.0.2 """ +from typing import Any + from testslide import TestCase from pytcp.lib.int_checks import UINT_16__MAX, UINT_16__MIN @@ -58,7 +60,8 @@ def setUp(self) -> None: message constructor. """ - self._message_kwargs = { + self._args: list[Any] = [] + self._kwargs: dict[str, Any] = { "code": Icmp6NdNeighborSolicitationCode.DEFAULT, "cksum": 0, "target_address": Ip6Address(), @@ -73,12 +76,10 @@ def test__icmp6__nd__neighbor_solicitation__code__not_Icmp6NdNeighborSolicitatio provided 'code' argument is not an Icmp6NdNeighborSolicitationCode. """ - self._message_kwargs["code"] = value = ( - "not an Icmp6NdNeighborSolicitationCode" - ) + self._kwargs["code"] = value = "not an Icmp6NdNeighborSolicitationCode" with self.assertRaises(AssertionError) as error: - Icmp6NdNeighborSolicitationMessage(**self._message_kwargs) # type: ignore + Icmp6NdNeighborSolicitationMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -97,10 +98,10 @@ def test__icmp6__nd__neighbor_solicitation__cksum__under_min( the minimum supported value. """ - self._message_kwargs["cksum"] = value = UINT_16__MIN - 1 + self._kwargs["cksum"] = value = UINT_16__MIN - 1 with self.assertRaises(AssertionError) as error: - Icmp6NdNeighborSolicitationMessage(**self._message_kwargs) # type: ignore + Icmp6NdNeighborSolicitationMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -119,10 +120,10 @@ def test__icmp6__nd__neighbor_solicitation__cksum__over_max( the maximum supported value. """ - self._message_kwargs["cksum"] = value = UINT_16__MAX + 1 + self._kwargs["cksum"] = value = UINT_16__MAX + 1 with self.assertRaises(AssertionError) as error: - Icmp6NdNeighborSolicitationMessage(**self._message_kwargs) # type: ignore + Icmp6NdNeighborSolicitationMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -140,10 +141,10 @@ def test__icmp6__nd__neighbor_solicitation__target_address__not_Ip6Address( provided 'target_address' argument is not an Ip6Address. """ - self._message_kwargs["target_address"] = value = "not an Ip6Address" + self._kwargs["target_address"] = value = "not an Ip6Address" with self.assertRaises(AssertionError) as error: - Icmp6NdNeighborSolicitationMessage(**self._message_kwargs) # type: ignore + Icmp6NdNeighborSolicitationMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -161,10 +162,10 @@ def test__icmp6__nd__neighbor_solicitation__options__not_Icmp6NdOptions( provided 'options' argument is not an Icmp6NdOptions. """ - self._message_kwargs["options"] = value = "not an Icmp6NdOptions" + self._kwargs["options"] = value = "not an Icmp6NdOptions" with self.assertRaises(AssertionError) as error: - Icmp6NdNeighborSolicitationMessage(**self._message_kwargs) # type: ignore + Icmp6NdNeighborSolicitationMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), diff --git a/tests/unit/protocols/icmp6/test__icmp6__nd__router_advertisement__asserts.py b/tests/unit/protocols/icmp6/test__icmp6__nd__router_advertisement__asserts.py index 14cd14fa..de48a670 100644 --- a/tests/unit/protocols/icmp6/test__icmp6__nd__router_advertisement__asserts.py +++ b/tests/unit/protocols/icmp6/test__icmp6__nd__router_advertisement__asserts.py @@ -33,6 +33,8 @@ ver 3.0.2 """ +from typing import Any + from testslide import TestCase from pytcp.lib.int_checks import ( @@ -64,7 +66,8 @@ def setUp(self) -> None: message constructor. """ - self._message_kwargs = { + self._args: list[Any] = [] + self._kwargs: dict[str, Any] = { "code": Icmp6NdRouterAdvertisementCode.DEFAULT, "cksum": 0, "hop": 0, @@ -84,12 +87,10 @@ def test__icmp6__nd__router_advertisement__code__not_Icmp6NdRouterAdvertisementC provided 'code' argument is not an Icmp6NdRouterAdvertisementCode. """ - self._message_kwargs["code"] = value = ( - "not an Icmp6NdRouterAdvertisementCode" - ) + self._kwargs["code"] = value = "not an Icmp6NdRouterAdvertisementCode" with self.assertRaises(AssertionError) as error: - Icmp6NdRouterAdvertisementMessage(**self._message_kwargs) # type: ignore + Icmp6NdRouterAdvertisementMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -108,10 +109,10 @@ def test__icmp6__nd__router_advertisement__cksum__under_min( the minimum supported value. """ - self._message_kwargs["cksum"] = value = UINT_16__MIN - 1 + self._kwargs["cksum"] = value = UINT_16__MIN - 1 with self.assertRaises(AssertionError) as error: - Icmp6NdRouterAdvertisementMessage(**self._message_kwargs) # type: ignore + Icmp6NdRouterAdvertisementMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -130,10 +131,10 @@ def test__icmp6__nd__router_advertisement__cksum__over_max( the maximum supported value. """ - self._message_kwargs["cksum"] = value = UINT_16__MAX + 1 + self._kwargs["cksum"] = value = UINT_16__MAX + 1 with self.assertRaises(AssertionError) as error: - Icmp6NdRouterAdvertisementMessage(**self._message_kwargs) # type: ignore + Icmp6NdRouterAdvertisementMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -152,10 +153,10 @@ def test__icmp6__nd__router_advertisement__hop__under_min( the minimum supported value. """ - self._message_kwargs["hop"] = value = UINT_8__MIN - 1 + self._kwargs["hop"] = value = UINT_8__MIN - 1 with self.assertRaises(AssertionError) as error: - Icmp6NdRouterAdvertisementMessage(**self._message_kwargs) # type: ignore + Icmp6NdRouterAdvertisementMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -174,10 +175,10 @@ def test__icmp6__nd__router_advertisement__hop__over_max( the maximum supported value. """ - self._message_kwargs["hop"] = value = UINT_8__MAX + 1 + self._kwargs["hop"] = value = UINT_8__MAX + 1 with self.assertRaises(AssertionError) as error: - Icmp6NdRouterAdvertisementMessage(**self._message_kwargs) # type: ignore + Icmp6NdRouterAdvertisementMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -195,10 +196,10 @@ def test__icmp6__nd__router_advertisement__flag_m__not_boolean( provided 'flag_m' argument is not an Icmp6NdRouterAdvertisementCode. """ - self._message_kwargs["flag_m"] = value = "not a boolean" + self._kwargs["flag_m"] = value = "not a boolean" with self.assertRaises(AssertionError) as error: - Icmp6NdRouterAdvertisementMessage(**self._message_kwargs) # type: ignore + Icmp6NdRouterAdvertisementMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -214,10 +215,10 @@ def test__icmp6__nd__router_advertisement__router_lifetime__under_min( than the minimum supported value. """ - self._message_kwargs["router_lifetime"] = value = UINT_16__MIN - 1 + self._kwargs["router_lifetime"] = value = UINT_16__MIN - 1 with self.assertRaises(AssertionError) as error: - Icmp6NdRouterAdvertisementMessage(**self._message_kwargs) # type: ignore + Icmp6NdRouterAdvertisementMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -236,10 +237,10 @@ def test__icmp6__nd__router_advertisement__router_lifetime__over_max( than the maximum supported value. """ - self._message_kwargs["router_lifetime"] = value = UINT_16__MAX + 1 + self._kwargs["router_lifetime"] = value = UINT_16__MAX + 1 with self.assertRaises(AssertionError) as error: - Icmp6NdRouterAdvertisementMessage(**self._message_kwargs) # type: ignore + Icmp6NdRouterAdvertisementMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -258,10 +259,10 @@ def test__icmp6__nd__router_advertisement__reachable_time__under_min( than the minimum supported value. """ - self._message_kwargs["reachable_time"] = value = UINT_32__MIN - 1 + self._kwargs["reachable_time"] = value = UINT_32__MIN - 1 with self.assertRaises(AssertionError) as error: - Icmp6NdRouterAdvertisementMessage(**self._message_kwargs) # type: ignore + Icmp6NdRouterAdvertisementMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -280,10 +281,10 @@ def test__icmp6__nd__router_advertisement__reachable_time__over_max( than the maximum supported value. """ - self._message_kwargs["reachable_time"] = value = UINT_32__MAX + 1 + self._kwargs["reachable_time"] = value = UINT_32__MAX + 1 with self.assertRaises(AssertionError) as error: - Icmp6NdRouterAdvertisementMessage(**self._message_kwargs) # type: ignore + Icmp6NdRouterAdvertisementMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -302,10 +303,10 @@ def test__icmp6__nd__router_advertisement__retrans_timer__under_min( than the minimum supported value. """ - self._message_kwargs["retrans_timer"] = value = UINT_32__MIN - 1 + self._kwargs["retrans_timer"] = value = UINT_32__MIN - 1 with self.assertRaises(AssertionError) as error: - Icmp6NdRouterAdvertisementMessage(**self._message_kwargs) # type: ignore + Icmp6NdRouterAdvertisementMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -324,10 +325,10 @@ def test__icmp6__nd__router_advertisement__retrans_timer__over_max( than the maximum supported value. """ - self._message_kwargs["retrans_timer"] = value = UINT_32__MAX + 1 + self._kwargs["retrans_timer"] = value = UINT_32__MAX + 1 with self.assertRaises(AssertionError) as error: - Icmp6NdRouterAdvertisementMessage(**self._message_kwargs) # type: ignore + Icmp6NdRouterAdvertisementMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -345,10 +346,10 @@ def test__icmp6__nd__router_advertisement__options__not_Icmp6NdOptions( provided 'options' argument is not an Icmp6NdOptions. """ - self._message_kwargs["options"] = value = "not an Icmp6NdOptions" + self._kwargs["options"] = value = "not an Icmp6NdOptions" with self.assertRaises(AssertionError) as error: - Icmp6NdRouterAdvertisementMessage(**self._message_kwargs) # type: ignore + Icmp6NdRouterAdvertisementMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), diff --git a/tests/unit/protocols/icmp6/test__icmp6__nd__router_solicitation__asserts.py b/tests/unit/protocols/icmp6/test__icmp6__nd__router_solicitation__asserts.py index 961c5117..32e32c15 100644 --- a/tests/unit/protocols/icmp6/test__icmp6__nd__router_solicitation__asserts.py +++ b/tests/unit/protocols/icmp6/test__icmp6__nd__router_solicitation__asserts.py @@ -33,6 +33,8 @@ ver 3.0.2 """ +from typing import Any + from testslide import TestCase from pytcp.lib.int_checks import UINT_16__MAX, UINT_16__MIN @@ -57,7 +59,8 @@ def setUp(self) -> None: constructor. """ - self._message_kwargs = { + self._args: list[Any] = [] + self._kwargs: dict[str, Any] = { "code": Icmp6NdRouterSolicitationCode.DEFAULT, "cksum": 0, "options": Icmp6NdOptions(), @@ -71,12 +74,10 @@ def test__icmp6__nd__router_solicitation__code__not_Icmp6NdRouterSolicitationCod provided 'code' argument is not an Icmp6NdRouterSolicitationCode. """ - self._message_kwargs["code"] = value = ( - "not an Icmp6NdRouterSolicitationCode" - ) + self._kwargs["code"] = value = "not an Icmp6NdRouterSolicitationCode" with self.assertRaises(AssertionError) as error: - Icmp6NdRouterSolicitationMessage(**self._message_kwargs) # type: ignore + Icmp6NdRouterSolicitationMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -95,10 +96,10 @@ def test__icmp6__nd__router_solicitation__cksum__under_min( the minimum supported value. """ - self._message_kwargs["cksum"] = value = UINT_16__MIN - 1 + self._kwargs["cksum"] = value = UINT_16__MIN - 1 with self.assertRaises(AssertionError) as error: - Icmp6NdRouterSolicitationMessage(**self._message_kwargs) # type: ignore + Icmp6NdRouterSolicitationMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -117,10 +118,10 @@ def test__icmp6__nd__router_solicitation__cksum__over_max( the maximum supported value. """ - self._message_kwargs["cksum"] = value = UINT_16__MAX + 1 + self._kwargs["cksum"] = value = UINT_16__MAX + 1 with self.assertRaises(AssertionError) as error: - Icmp6NdRouterSolicitationMessage(**self._message_kwargs) # type: ignore + Icmp6NdRouterSolicitationMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -138,10 +139,10 @@ def test__icmp6__nd__router_solicitation__options__not_Icmp6NdOptions( provided 'options' argument is not an Icmp6NdOptions. """ - self._message_kwargs["options"] = value = "not an Icmp6NdOptions" + self._kwargs["options"] = value = "not an Icmp6NdOptions" with self.assertRaises(AssertionError) as error: - Icmp6NdRouterSolicitationMessage(**self._message_kwargs) # type: ignore + Icmp6NdRouterSolicitationMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), diff --git a/tests/unit/protocols/icmp6/test__icmp6__unknown__asserts.py b/tests/unit/protocols/icmp6/test__icmp6__unknown__asserts.py index 26797be4..5afdd354 100644 --- a/tests/unit/protocols/icmp6/test__icmp6__unknown__asserts.py +++ b/tests/unit/protocols/icmp6/test__icmp6__unknown__asserts.py @@ -33,6 +33,8 @@ """ +from typing import Any + from testslide import TestCase from pytcp.lib.inet_cksum import inet_cksum @@ -54,7 +56,8 @@ def setUp(self) -> None: constructor. """ - self._message_kwargs = { + self._args: list[Any] = [] + self._kwargs: dict[str, Any] = { "type": Icmp6Type.from_int(255), "code": Icmp6Code.from_int(255), "cksum": 0, @@ -67,10 +70,10 @@ def test__icmp6__unknown__type__not_Icmp6Type(self) -> None: provided 'type' argument is not an Icmp6Type. """ - self._message_kwargs["type"] = value = "not an Icmp6Type" + self._kwargs["type"] = value = "not an Icmp6Type" with self.assertRaises(AssertionError) as error: - Icmp6UnknownMessage(**self._message_kwargs) # type: ignore + Icmp6UnknownMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -83,10 +86,10 @@ def test__icmp6__unknown__code__not_Icmp6Code(self) -> None: provided 'code' argument is not an Icmp6Code. """ - self._message_kwargs["code"] = value = "not an Icmp6Code" + self._kwargs["code"] = value = "not an Icmp6Code" with self.assertRaises(AssertionError) as error: - Icmp6UnknownMessage(**self._message_kwargs) # type: ignore + Icmp6UnknownMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -100,10 +103,10 @@ def test__icmp6__echo_request__cksum__under_min(self) -> None: minimum supported value. """ - self._message_kwargs["cksum"] = value = UINT_16__MIN - 1 + self._kwargs["cksum"] = value = UINT_16__MIN - 1 with self.assertRaises(AssertionError) as error: - Icmp6UnknownMessage(**self._message_kwargs) # type: ignore + Icmp6UnknownMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -117,10 +120,10 @@ def test__icmp6__echo_request__cksum__over_max(self) -> None: maximum supported value. """ - self._message_kwargs["cksum"] = value = UINT_16__MAX + 1 + self._kwargs["cksum"] = value = UINT_16__MAX + 1 with self.assertRaises(AssertionError) as error: - Icmp6UnknownMessage(**self._message_kwargs) # type: ignore + Icmp6UnknownMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception), @@ -134,10 +137,10 @@ def test__icmp6__unknown__raw__not_bytes(self) -> None: provided 'raw' argument is not bytes. """ - self._message_kwargs["raw"] = value = "not bytes or memoryview" + self._kwargs["raw"] = value = "not bytes or memoryview" with self.assertRaises(AssertionError) as error: - Icmp6UnknownMessage(**self._message_kwargs) # type: ignore + Icmp6UnknownMessage(*self._args, **self._kwargs) self.assertEqual( str(error.exception),