diff --git a/pytcp/lib/errors.py b/pytcp/lib/errors.py index ea3f96ab..4ce5dbf9 100755 --- a/pytcp/lib/errors.py +++ b/pytcp/lib/errors.py @@ -53,7 +53,7 @@ class PacketIntegrityError(PacketValidationError): Exception raised when integrity check fails. """ - def __init__(self, /, message: str): + def __init__(self, message: str, /): super().__init__("[INTEGRITY ERROR]" + message) @@ -62,5 +62,5 @@ class PacketSanityError(PacketValidationError): Exception raised when sanity check fails. """ - def __init__(self, /, message: str): + def __init__(self, message: str, /): super().__init__("[SANITY ERROR]" + message) diff --git a/pytcp/lib/net_addr/errors.py b/pytcp/lib/net_addr/errors.py index 7658624f..05243612 100644 --- a/pytcp/lib/net_addr/errors.py +++ b/pytcp/lib/net_addr/errors.py @@ -79,7 +79,7 @@ class Ip4AddressFormatError(IpAddressFormatError): Exception raised when IPv4 address format is invalid. """ - def __init__(self, /, message: Any): + def __init__(self, message: Any, /): super().__init__(f"The IPv4 address format is invalid: {message!r}") @@ -88,7 +88,7 @@ class Ip4MaskFormatError(IpMaskFormatError): Exception raised when IPv4 mask format is invalid. """ - def __init__(self, /, message: Any): + def __init__(self, message: Any, /): super().__init__(f"The IPv4 mask format is invalid: {message!r}") @@ -97,7 +97,7 @@ class Ip4NetworkFormatError(IpNetworkFormatError): Exception raised when IPv4 network format is invalid. """ - def __init__(self, /, message: Any): + def __init__(self, message: Any, /): super().__init__(f"The IPv4 network format is invalid: {message!r}") @@ -106,7 +106,7 @@ class Ip4HostFormatError(IpHostFormatError): Exception raised when IPv4 host format is invalid. """ - def __init__(self, /, message: Any): + def __init__(self, message: Any, /): super().__init__(f"The IPv4 host format is invalid: {message!r}") @@ -115,7 +115,7 @@ class Ip4HostGatewayError(IpHostGatewayError): Exception raised when IPv4 host gateway is invalid. """ - def __init__(self, /, message: Any): + def __init__(self, message: Any, /): super().__init__(f"The IPv4 host gateway is invalid: {message!r}") @@ -124,7 +124,7 @@ class Ip6AddressFormatError(IpAddressFormatError): Exception raised when IPv6 address format is invalid. """ - def __init__(self, /, message: Any): + def __init__(self, message: Any, /): super().__init__(f"The IPv6 address format is invalid: {message!r}") @@ -133,7 +133,7 @@ class Ip6MaskFormatError(IpMaskFormatError): Exception raised when IPv6 mask format is invalid. """ - def __init__(self, /, message: Any): + def __init__(self, message: Any, /): super().__init__(f"The IPv6 mask format is invalid: {message!r}") @@ -142,7 +142,7 @@ class Ip6NetworkFormatError(IpNetworkFormatError): Exception raised when IPv6 network format is invalid. """ - def __init__(self, /, message: Any): + def __init__(self, message: Any, /): super().__init__(f"The IPv6 network format is invalid: {message!r}") @@ -151,7 +151,7 @@ class Ip6HostFormatError(IpHostFormatError): Exception raised when IPv6 host format is invalid. """ - def __init__(self, /, message: Any): + def __init__(self, message: Any, /): super().__init__(f"The IPv6 host format is invalid: {message!r}") @@ -160,7 +160,7 @@ class Ip6HostGatewayError(IpHostGatewayError): Exception raised when IPv6 host gateway is invalid. """ - def __init__(self, /, message: Any): + def __init__(self, message: Any, /): super().__init__(f"The IPv6 host gateway is invalid: {message!r}") @@ -169,5 +169,5 @@ class MacAddressFormatError(Exception): Exception raised when MAC address format is invalid. """ - def __init__(self, /, message: Any): + def __init__(self, message: Any, /): super().__init__(f"The MAC address format is invalid: {message!r}") diff --git a/pytcp/lib/net_addr/ip4_address.py b/pytcp/lib/net_addr/ip4_address.py index 31537ccb..48318ba9 100755 --- a/pytcp/lib/net_addr/ip4_address.py +++ b/pytcp/lib/net_addr/ip4_address.py @@ -60,10 +60,10 @@ class Ip4Address(IpAddress): def __init__( self, - /, address: ( Ip4Address | str | bytes | bytearray | memoryview | int | None ) = None, + /, ) -> None: """ Create a new IPv4 address object. diff --git a/pytcp/lib/net_addr/ip4_mask.py b/pytcp/lib/net_addr/ip4_mask.py index ec7a8936..f314cfb8 100755 --- a/pytcp/lib/net_addr/ip4_mask.py +++ b/pytcp/lib/net_addr/ip4_mask.py @@ -53,10 +53,10 @@ class Ip4Mask(IpMask): def __init__( self, - /, mask: ( Ip4Mask | str | bytes | bytearray | memoryview | int | None ) = None, + /, ) -> None: """ Create a new IPv4 mask object. diff --git a/pytcp/lib/net_addr/ip6_address.py b/pytcp/lib/net_addr/ip6_address.py index 9e6f515e..65ae26ee 100755 --- a/pytcp/lib/net_addr/ip6_address.py +++ b/pytcp/lib/net_addr/ip6_address.py @@ -67,10 +67,10 @@ class Ip6Address(IpAddress): def __init__( self, - /, address: ( Ip6Address | str | bytes | bytearray | memoryview | int | None ) = None, + /, ) -> None: """ Create a new IPv6 address object. diff --git a/pytcp/lib/net_addr/mac_address.py b/pytcp/lib/net_addr/mac_address.py index 52a426c6..ed82d903 100755 --- a/pytcp/lib/net_addr/mac_address.py +++ b/pytcp/lib/net_addr/mac_address.py @@ -52,10 +52,10 @@ class MacAddress(Address): def __init__( self, - /, address: ( MacAddress | str | bytes | bytearray | memoryview | int | None ) = None, + /, ) -> None: """ Create a new MAC address object. diff --git a/pytcp/protocols/arp/arp__errors.py b/pytcp/protocols/arp/arp__errors.py index d744b094..7644af5f 100755 --- a/pytcp/protocols/arp/arp__errors.py +++ b/pytcp/protocols/arp/arp__errors.py @@ -43,7 +43,7 @@ class ArpIntegrityError(PacketIntegrityError): Exception raised when ARP packet integrity check fails. """ - def __init__(self, /, message: str): + def __init__(self, message: str, /): super().__init__("[ARP] " + message) @@ -52,5 +52,5 @@ class ArpSanityError(PacketSanityError): Exception raised when ARP packet sanity check fails. """ - def __init__(self, /, message: str): + def __init__(self, message: str, /): super().__init__("[ARP] " + message) diff --git a/pytcp/protocols/ethernet/ethernet__errors.py b/pytcp/protocols/ethernet/ethernet__errors.py index 026c14ff..ac9a55d2 100755 --- a/pytcp/protocols/ethernet/ethernet__errors.py +++ b/pytcp/protocols/ethernet/ethernet__errors.py @@ -43,7 +43,7 @@ class EthernetIntegrityError(PacketIntegrityError): Exception raised when Ethernet packet integrity check fails. """ - def __init__(self, /, message: str): + def __init__(self, message: str, /): super().__init__("[Ethernet] " + message) @@ -52,5 +52,5 @@ class EthernetSanityError(PacketSanityError): Exception raised when Ethernet packet sanity check fails. """ - def __init__(self, /, message: str): + def __init__(self, message: str, /): super().__init__("[Ethernet] " + message) diff --git a/pytcp/protocols/ethernet_802_3/ethernet_802_3__errors.py b/pytcp/protocols/ethernet_802_3/ethernet_802_3__errors.py index 9ad5ce3c..1f6fe1de 100755 --- a/pytcp/protocols/ethernet_802_3/ethernet_802_3__errors.py +++ b/pytcp/protocols/ethernet_802_3/ethernet_802_3__errors.py @@ -43,7 +43,7 @@ class Ethernet8023IntegrityError(PacketIntegrityError): Exception raised when Ethernet 802.3 packet integrity check fails. """ - def __init__(self, /, message: str): + def __init__(self, message: str, /): super().__init__("[Ethernet 802.3] " + message) @@ -52,5 +52,5 @@ class Ethernet8023SanityError(PacketSanityError): Exception raised when Ethernet 802.3 packet sanity check fails. """ - def __init__(self, /, message: str): + def __init__(self, message: str, /): super().__init__("[Ethernet 802.3] " + message) diff --git a/pytcp/protocols/icmp4/icmp4__errors.py b/pytcp/protocols/icmp4/icmp4__errors.py index 821648f8..2a42d89e 100755 --- a/pytcp/protocols/icmp4/icmp4__errors.py +++ b/pytcp/protocols/icmp4/icmp4__errors.py @@ -43,7 +43,7 @@ class Icmp4IntegrityError(PacketIntegrityError): The ICMPv4 packet integrity check failure. """ - def __init__(self, /, message: str): + def __init__(self, message: str, /): super().__init__("[ICMPv4] " + message) @@ -52,5 +52,5 @@ class Icmp4SanityError(PacketSanityError): The ICMPv4 packet sanity check failure. """ - def __init__(self, /, message: str): + def __init__(self, message: str, /): super().__init__("[ICMPv4] " + message) diff --git a/pytcp/protocols/icmp6/icmp6__errors.py b/pytcp/protocols/icmp6/icmp6__errors.py index 83417091..1cad12b5 100755 --- a/pytcp/protocols/icmp6/icmp6__errors.py +++ b/pytcp/protocols/icmp6/icmp6__errors.py @@ -43,7 +43,7 @@ class Icmp6IntegrityError(PacketIntegrityError): Exception raised when ICMPv6 packet integrity check fails. """ - def __init__(self, /, message: str): + def __init__(self, message: str, /): super().__init__("[ICMPv6] " + message) @@ -52,5 +52,5 @@ class Icmp6SanityError(PacketSanityError): Exception raised when ICMPv6 packet sanity check fails. """ - def __init__(self, /, message: str): + def __init__(self, message: str, /): super().__init__("[ICMPv6] " + message) diff --git a/pytcp/protocols/ip4/ip4__errors.py b/pytcp/protocols/ip4/ip4__errors.py index 389b4c8e..80a86c9a 100755 --- a/pytcp/protocols/ip4/ip4__errors.py +++ b/pytcp/protocols/ip4/ip4__errors.py @@ -43,7 +43,7 @@ class Ip4IntegrityError(PacketIntegrityError): Exception raised when IPv4 packet integrity check fails. """ - def __init__(self, /, message: str): + def __init__(self, message: str, /): super().__init__("[IPv4] " + message) @@ -52,5 +52,5 @@ class Ip4SanityError(PacketSanityError): Exception raised when IPv4 packet sanity check fails. """ - def __init__(self, /, message: str): + def __init__(self, message: str, /): super().__init__("[IPv4] " + message) diff --git a/pytcp/protocols/ip6/ip6__errors.py b/pytcp/protocols/ip6/ip6__errors.py index fd2c86fb..0e790877 100755 --- a/pytcp/protocols/ip6/ip6__errors.py +++ b/pytcp/protocols/ip6/ip6__errors.py @@ -43,7 +43,7 @@ class Ip6IntegrityError(PacketIntegrityError): Exception raised when IPv6 packet integrity check fails. """ - def __init__(self, /, message: str): + def __init__(self, message: str, /): super().__init__("[IPv6] " + message) @@ -52,5 +52,5 @@ class Ip6SanityError(PacketSanityError): Exception raised when IPv6 packet sanity check fails. """ - def __init__(self, /, message: str): + def __init__(self, message: str, /): super().__init__("[IPv6] " + message) diff --git a/pytcp/protocols/ip6_ext_frag/ip6_ext_frag__errors.py b/pytcp/protocols/ip6_ext_frag/ip6_ext_frag__errors.py index 09bafa1a..f1b2d4af 100755 --- a/pytcp/protocols/ip6_ext_frag/ip6_ext_frag__errors.py +++ b/pytcp/protocols/ip6_ext_frag/ip6_ext_frag__errors.py @@ -43,7 +43,7 @@ class Ip6ExtFragIntegrityError(PacketIntegrityError): Exception raised when IPv6 Ext Frag packet integrity check fails. """ - def __init__(self, /, message: str): + def __init__(self, message: str, /): super().__init__("[IPv6 Ext Frag] " + message) @@ -52,5 +52,5 @@ class Ip6ExtFragSanityError(PacketSanityError): Exception raised when IPv6 Ext Frag packet sanity check fails. """ - def __init__(self, /, message: str): + def __init__(self, message: str, /): super().__init__("[IPv6 Ext Frag] " + message) diff --git a/pytcp/protocols/tcp/tcp__errors.py b/pytcp/protocols/tcp/tcp__errors.py index 45371290..6810ef99 100755 --- a/pytcp/protocols/tcp/tcp__errors.py +++ b/pytcp/protocols/tcp/tcp__errors.py @@ -43,7 +43,7 @@ class TcpIntegrityError(PacketIntegrityError): Exception raised when TCP packet integrity check fails. """ - def __init__(self, /, message: str): + def __init__(self, message: str, /): super().__init__("[TCP] " + message) @@ -52,5 +52,5 @@ class TcpSanityError(PacketSanityError): Exception raised when TCP packet sanity check fails. """ - def __init__(self, /, message: str): + def __init__(self, message: str, /): super().__init__("[TCP] " + message) diff --git a/pytcp/protocols/udp/udp__errors.py b/pytcp/protocols/udp/udp__errors.py index d9f4c763..bc595f4c 100755 --- a/pytcp/protocols/udp/udp__errors.py +++ b/pytcp/protocols/udp/udp__errors.py @@ -43,7 +43,7 @@ class UdpIntegrityError(PacketIntegrityError): Exception raised when UDP packet integrity check fails. """ - def __init__(self, /, message: str): + def __init__(self, message: str, /): super().__init__("[UDP] " + message) @@ -52,5 +52,5 @@ class UdpSanityError(PacketSanityError): Exception raised when UDP packet sanity check fails. """ - def __init__(self, /, message: str): + def __init__(self, message: str, /): super().__init__("[UDP] " + message) diff --git a/tests/unit/lib/net_addr/test__ip4_address.py b/tests/unit/lib/net_addr/test__ip4_address.py index 650bfe7b..0c1ea161 100644 --- a/tests/unit/lib/net_addr/test__ip4_address.py +++ b/tests/unit/lib/net_addr/test__ip4_address.py @@ -45,9 +45,7 @@ [ { "_description": "Test the IPv4 address: 0.0.0.0 (str)", - "_args": { - "address": "0.0.0.0", - }, + "_args": ["0.0.0.0"], "_results": { "__str__": "0.0.0.0", "__repr__": "Ip4Address('0.0.0.0')", @@ -72,9 +70,7 @@ }, { "_description": "Test the IPv4 address: 0.0.0.0 (None)", - "_args": { - "address": None, - }, + "_args": [None], "_results": { "__str__": "0.0.0.0", "__repr__": "Ip4Address('0.0.0.0')", @@ -99,9 +95,7 @@ }, { "_description": "Test the IPv4 address: 0.0.0.1 (str)", - "_args": { - "address": "0.0.0.1", - }, + "_args": ["0.0.0.1"], "_results": { "__str__": "0.0.0.1", "__repr__": "Ip4Address('0.0.0.1')", @@ -126,9 +120,7 @@ }, { "_description": "Test the IPv4 address: 0.255.255.255 (str)", - "_args": { - "address": "0.255.255.255", - }, + "_args": ["0.255.255.255"], "_results": { "__str__": "0.255.255.255", "__repr__": "Ip4Address('0.255.255.255')", @@ -153,9 +145,7 @@ }, { "_description": "Test the IPv4 address: 1.0.0.0 (str)", - "_args": { - "address": "1.0.0.0", - }, + "_args": ["1.0.0.0"], "_results": { "__str__": "1.0.0.0", "__repr__": "Ip4Address('1.0.0.0')", @@ -180,9 +170,7 @@ }, { "_description": "Test the IPv4 address: 9.255.255.255 (str)", - "_args": { - "address": "9.255.255.255", - }, + "_args": ["9.255.255.255"], "_results": { "__str__": "9.255.255.255", "__repr__": "Ip4Address('9.255.255.255')", @@ -207,9 +195,7 @@ }, { "_description": "Test the IPv4 address: 10.0.0.0 (str)", - "_args": { - "address": "10.0.0.0", - }, + "_args": ["10.0.0.0"], "_results": { "__str__": "10.0.0.0", "__repr__": "Ip4Address('10.0.0.0')", @@ -234,9 +220,7 @@ }, { "_description": "Test the IPv4 address: 10.255.255.255 (str)", - "_args": { - "address": "10.255.255.255", - }, + "_args": ["10.255.255.255"], "_results": { "__str__": "10.255.255.255", "__repr__": "Ip4Address('10.255.255.255')", @@ -261,9 +245,7 @@ }, { "_description": "Test the IPv4 address: 11.0.0.0 (str)", - "_args": { - "address": "11.0.0.0", - }, + "_args": ["11.0.0.0"], "_results": { "__str__": "11.0.0.0", "__repr__": "Ip4Address('11.0.0.0')", @@ -288,9 +270,7 @@ }, { "_description": "Test the IPv4 address: 126.255.255.255 (str)", - "_args": { - "address": "126.255.255.255", - }, + "_args": ["126.255.255.255"], "_results": { "__str__": "126.255.255.255", "__repr__": "Ip4Address('126.255.255.255')", @@ -315,9 +295,7 @@ }, { "_description": "Test the IPv4 address: 127.0.0.0 (str)", - "_args": { - "address": "127.0.0.0", - }, + "_args": ["127.0.0.0"], "_results": { "__str__": "127.0.0.0", "__repr__": "Ip4Address('127.0.0.0')", @@ -342,9 +320,7 @@ }, { "_description": "Test the IPv4 address: 127.255.255.255 (str)", - "_args": { - "address": "127.255.255.255", - }, + "_args": ["127.255.255.255"], "_results": { "__str__": "127.255.255.255", "__repr__": "Ip4Address('127.255.255.255')", @@ -369,9 +345,7 @@ }, { "_description": "Test the IPv4 address: 128.0.0.0 (str)", - "_args": { - "address": "128.0.0.0", - }, + "_args": ["128.0.0.0"], "_results": { "__str__": "128.0.0.0", "__repr__": "Ip4Address('128.0.0.0')", @@ -396,9 +370,7 @@ }, { "_description": "Test the IPv4 address: 169.253.255.255 (str)", - "_args": { - "address": "169.253.255.255", - }, + "_args": ["169.253.255.255"], "_results": { "__str__": "169.253.255.255", "__repr__": "Ip4Address('169.253.255.255')", @@ -423,9 +395,7 @@ }, { "_description": "Test the IPv4 address: 169.255.0.0 (str)", - "_args": { - "address": "169.255.0.0", - }, + "_args": ["169.255.0.0"], "_results": { "__str__": "169.255.0.0", "__repr__": "Ip4Address('169.255.0.0')", @@ -450,9 +420,7 @@ }, { "_description": "Test the IPv4 address: 170.0.0.0 (str)", - "_args": { - "address": "170.0.0.0", - }, + "_args": ["170.0.0.0"], "_results": { "__str__": "170.0.0.0", "__repr__": "Ip4Address('170.0.0.0')", @@ -477,9 +445,7 @@ }, { "_description": "Test the IPv4 address: 172.15.255.255 (str)", - "_args": { - "address": "172.15.255.255", - }, + "_args": ["172.15.255.255"], "_results": { "__str__": "172.15.255.255", "__repr__": "Ip4Address('172.15.255.255')", @@ -504,9 +470,7 @@ }, { "_description": "Test the IPv4 address: 172.16.0.0 (str)", - "_args": { - "address": "172.16.0.0", - }, + "_args": ["172.16.0.0"], "_results": { "__str__": "172.16.0.0", "__repr__": "Ip4Address('172.16.0.0')", @@ -531,9 +495,7 @@ }, { "_description": "Test the IPv4 address: 172.31.255.255 (str)", - "_args": { - "address": "172.31.255.255", - }, + "_args": ["172.31.255.255"], "_results": { "__str__": "172.31.255.255", "__repr__": "Ip4Address('172.31.255.255')", @@ -558,9 +520,7 @@ }, { "_description": "Test the IPv4 address: 172.32.0.0 (str)", - "_args": { - "address": "172.32.0.0", - }, + "_args": ["172.32.0.0"], "_results": { "__str__": "172.32.0.0", "__repr__": "Ip4Address('172.32.0.0')", @@ -585,9 +545,7 @@ }, { "_description": "Test the IPv4 address: 192.167.255.255 (str)", - "_args": { - "address": "192.167.255.255", - }, + "_args": ["192.167.255.255"], "_results": { "__str__": "192.167.255.255", "__repr__": "Ip4Address('192.167.255.255')", @@ -612,9 +570,7 @@ }, { "_description": "Test the IPv4 address: 192.168.0.0 (str)", - "_args": { - "address": "192.168.0.0", - }, + "_args": ["192.168.0.0"], "_results": { "__str__": "192.168.0.0", "__repr__": "Ip4Address('192.168.0.0')", @@ -639,9 +595,7 @@ }, { "_description": "Test the IPv4 address: 192.168.255.255 (str)", - "_args": { - "address": "192.168.255.255", - }, + "_args": ["192.168.255.255"], "_results": { "__str__": "192.168.255.255", "__repr__": "Ip4Address('192.168.255.255')", @@ -666,9 +620,7 @@ }, { "_description": "Test the IPv4 address: 192.168.255.255 (Ip4Address)", - "_args": { - "address": Ip4Address("192.168.255.255"), - }, + "_args": [Ip4Address("192.168.255.255")], "_results": { "__str__": "192.168.255.255", "__repr__": "Ip4Address('192.168.255.255')", @@ -693,9 +645,7 @@ }, { "_description": "Test the IPv4 address: 192.168.255.255 (int)", - "_args": { - "address": 3232301055, - }, + "_args": [3232301055], "_results": { "__str__": "192.168.255.255", "__repr__": "Ip4Address('192.168.255.255')", @@ -720,9 +670,7 @@ }, { "_description": "Test the IPv4 address: 192.168.255.255 (bytes)", - "_args": { - "address": b"\xc0\xa8\xff\xff", - }, + "_args": [b"\xc0\xa8\xff\xff"], "_results": { "__str__": "192.168.255.255", "__repr__": "Ip4Address('192.168.255.255')", @@ -747,9 +695,7 @@ }, { "_description": "Test the IPv4 address: 192.168.255.255 (bytearray)", - "_args": { - "address": bytearray(b"\xc0\xa8\xff\xff"), - }, + "_args": [bytearray(b"\xc0\xa8\xff\xff")], "_results": { "__str__": "192.168.255.255", "__repr__": "Ip4Address('192.168.255.255')", @@ -774,9 +720,7 @@ }, { "_description": "Test the IPv4 address: 192.168.255.255 (memoryview)", - "_args": { - "address": memoryview(b"\xc0\xa8\xff\xff"), - }, + "_args": [memoryview(b"\xc0\xa8\xff\xff")], "_results": { "__str__": "192.168.255.255", "__repr__": "Ip4Address('192.168.255.255')", @@ -801,9 +745,7 @@ }, { "_description": "Test the IPv4 address: 192.169.0.0 (str)", - "_args": { - "address": "192.169.0.0", - }, + "_args": ["192.169.0.0"], "_results": { "__str__": "192.169.0.0", "__repr__": "Ip4Address('192.169.0.0')", @@ -828,9 +770,7 @@ }, { "_description": "Test the IPv4 address: 223.255.255.255 (str)", - "_args": { - "address": "223.255.255.255", - }, + "_args": ["223.255.255.255"], "_results": { "__str__": "223.255.255.255", "__repr__": "Ip4Address('223.255.255.255')", @@ -855,9 +795,7 @@ }, { "_description": "Test the IPv4 address: 224.0.0.0 (str)", - "_args": { - "address": "224.0.0.0", - }, + "_args": ["224.0.0.0"], "_results": { "__str__": "224.0.0.0", "__repr__": "Ip4Address('224.0.0.0')", @@ -882,9 +820,7 @@ }, { "_description": "Test the IPv4 address: 239.255.255.255 (str)", - "_args": { - "address": "239.255.255.255", - }, + "_args": ["239.255.255.255"], "_results": { "__str__": "239.255.255.255", "__repr__": "Ip4Address('239.255.255.255')", @@ -909,9 +845,7 @@ }, { "_description": "Test the IPv4 address: 240.0.0.0 (str)", - "_args": { - "address": "240.0.0.0", - }, + "_args": ["240.0.0.0"], "_results": { "__str__": "240.0.0.0", "__repr__": "Ip4Address('240.0.0.0')", @@ -936,9 +870,7 @@ }, { "_description": "Test the IPv4 address: 255.255.255.254 (str)", - "_args": { - "address": "255.255.255.254", - }, + "_args": ["255.255.255.254"], "_results": { "__str__": "255.255.255.254", "__repr__": "Ip4Address('255.255.255.254')", @@ -963,9 +895,7 @@ }, { "_description": "Test the IPv4 address: 255.255.255.255 (str)", - "_args": { - "address": "255.255.255.255", - }, + "_args": ["255.255.255.255"], "_results": { "__str__": "255.255.255.255", "__repr__": "Ip4Address('255.255.255.255')", @@ -1004,7 +934,7 @@ def setUp(self) -> None: Initialize the IPv4 address object with testcase arguments. """ - self._ip4_address = Ip4Address(**self._args) + self._ip4_address = Ip4Address(*self._args) def test__net_addr__ip4_address__str(self) -> None: """ @@ -1231,9 +1161,7 @@ def test__net_addr__ip4_address__is_limited_broadcast(self) -> None: [ { "_description": "Test the IPv4 address format: '10.10.10.256'", - "_args": { - "address": "10.10.10.256", - }, + "_args": ["10.10.10.256"], "_results": { "error": Ip4AddressFormatError, "error_message": ( @@ -1243,9 +1171,7 @@ def test__net_addr__ip4_address__is_limited_broadcast(self) -> None: }, { "_description": "Test the IPv4 address format: '10.10..10'", - "_args": { - "address": "10.10..10", - }, + "_args": ["10.10..10"], "_results": { "error": Ip4AddressFormatError, "error_message": ( @@ -1255,9 +1181,7 @@ def test__net_addr__ip4_address__is_limited_broadcast(self) -> None: }, { "_description": "Test the IPv4 address format: '10.10.10,10'", - "_args": { - "address": "10.10.10,10", - }, + "_args": ["10.10.10,10"], "_results": { "error": Ip4AddressFormatError, "error_message": ( @@ -1267,9 +1191,7 @@ def test__net_addr__ip4_address__is_limited_broadcast(self) -> None: }, { "_description": "Test the IPv4 address format: b'\xff\xff\xff'", - "_args": { - "address": b"\xff\xff\xff", - }, + "_args": [b"\xff\xff\xff"], "_results": { "error": Ip4AddressFormatError, "error_message": ( @@ -1279,9 +1201,7 @@ def test__net_addr__ip4_address__is_limited_broadcast(self) -> None: }, { "_description": "Test the IPv4 address format: b'\xff\xff\xff\xff\xff'", - "_args": { - "address": b"\xff\xff\xff\xff\xff", - }, + "_args": [b"\xff\xff\xff\xff\xff"], "_results": { "error": Ip4AddressFormatError, "error_message": ( @@ -1291,9 +1211,7 @@ def test__net_addr__ip4_address__is_limited_broadcast(self) -> None: }, { "_description": "Test the IPv4 address format: -1", - "_args": { - "address": -1, - }, + "_args": [-1], "_results": { "error": Ip4AddressFormatError, "error_message": ("The IPv4 address format is invalid: -1"), @@ -1301,9 +1219,7 @@ def test__net_addr__ip4_address__is_limited_broadcast(self) -> None: }, { "_description": "Test the IPv4 address format: 4294967296", - "_args": { - "address": 4294967296, - }, + "_args": [4294967296], "_results": { "error": Ip4AddressFormatError, "error_message": ( @@ -1313,9 +1229,7 @@ def test__net_addr__ip4_address__is_limited_broadcast(self) -> None: }, { "_description": "Test the IPv4 address format: Ip6Address()", - "_args": { - "address": Ip6Address(), - }, + "_args": [Ip6Address()], "_results": { "error": Ip4AddressFormatError, "error_message": "The IPv4 address format is invalid: Ip6Address('::')", @@ -1323,9 +1237,7 @@ def test__net_addr__ip4_address__is_limited_broadcast(self) -> None: }, { "_description": "Test the IPv4 address format: {}", - "_args": { - "address": {}, - }, + "_args": [{}], "_results": { "error": Ip4AddressFormatError, "error_message": "The IPv4 address format is invalid: {}", @@ -1333,9 +1245,7 @@ def test__net_addr__ip4_address__is_limited_broadcast(self) -> None: }, { "_description": "Test the IPv4 address format: 1.1", - "_args": { - "address": 1.1, - }, + "_args": [1.1], "_results": { "error": Ip4AddressFormatError, "error_message": "The IPv4 address format is invalid: 1.1", @@ -1358,7 +1268,7 @@ def test__net_addr__ip4_address__errors(self) -> None: """ with self.assertRaises(self._results["error"]) as error: - Ip4Address(**self._args) + Ip4Address(*self._args) self.assertEqual( str(error.exception), diff --git a/tests/unit/lib/net_addr/test__ip4_mask.py b/tests/unit/lib/net_addr/test__ip4_mask.py index d4c86e83..dda73869 100644 --- a/tests/unit/lib/net_addr/test__ip4_mask.py +++ b/tests/unit/lib/net_addr/test__ip4_mask.py @@ -38,17 +38,14 @@ from parameterized import parameterized_class # type: ignore from testslide import TestCase -from pytcp.lib.net_addr import Ip4Mask -from pytcp.lib.net_addr.errors import IpMaskFormatError +from pytcp.lib.net_addr import Ip4Mask, Ip4MaskFormatError, Ip6Mask @parameterized_class( [ { "_description": "Test the IPv4 mask: 0.0.0.0 (str)", - "_args": { - "mask": "0.0.0.0", - }, + "_args": ["0.0.0.0"], "_results": { "__len__": 0, "__str__": "/0", @@ -63,9 +60,7 @@ }, { "_description": "Test the IPv4 mask: 0.0.0.0 (None)", - "_args": { - "mask": None, - }, + "_args": [None], "_results": { "__len__": 0, "__str__": "/0", @@ -80,9 +75,7 @@ }, { "_description": "Test the IPv4 mask: 255.0.0.0 (str)", - "_args": { - "mask": "255.0.0.0", - }, + "_args": ["255.0.0.0"], "_results": { "__len__": 8, "__str__": "/8", @@ -97,9 +90,7 @@ }, { "_description": "Test the IPv4 mask: 255.128.0.0 (str)", - "_args": { - "mask": "255.128.0.0", - }, + "_args": ["255.128.0.0"], "_results": { "__len__": 9, "__str__": "/9", @@ -114,9 +105,7 @@ }, { "_description": "Test the IPv4 mask: 255.128.0.0 (Ip4Mask)", - "_args": { - "mask": Ip4Mask("255.128.0.0"), - }, + "_args": [Ip4Mask("255.128.0.0")], "_results": { "__len__": 9, "__str__": "/9", @@ -131,9 +120,7 @@ }, { "_description": "Test the IPv4 mask: 255.128.0.0 (bytes)", - "_args": { - "mask": b"\xff\x80\x00\x00", - }, + "_args": [b"\xff\x80\x00\x00"], "_results": { "__len__": 9, "__str__": "/9", @@ -148,9 +135,7 @@ }, { "_description": "Test the IPv4 mask: 255.128.0.0 (bytearray)", - "_args": { - "mask": bytearray(b"\xff\x80\x00\x00"), - }, + "_args": [bytearray(b"\xff\x80\x00\x00")], "_results": { "__len__": 9, "__str__": "/9", @@ -165,9 +150,7 @@ }, { "_description": "Test the IPv4 mask: 255.128.0.0 (memoryview)", - "_args": { - "mask": memoryview(b"\xff\x80\x00\x00"), - }, + "_args": [memoryview(b"\xff\x80\x00\x00")], "_results": { "__len__": 9, "__str__": "/9", @@ -182,9 +165,7 @@ }, { "_description": "Test the IPv4 mask: 255.128.0.0 (int)", - "_args": { - "mask": 4286578688, - }, + "_args": [4286578688], "_results": { "__len__": 9, "__str__": "/9", @@ -199,9 +180,7 @@ }, { "_description": "Test the IPv4 mask: 255.255.0.0 (str)", - "_args": { - "mask": "255.255.0.0", - }, + "_args": ["255.255.0.0"], "_results": { "__len__": 16, "__str__": "/16", @@ -216,9 +195,7 @@ }, { "_description": "Test the IPv4 mask: 255.255.224.0 (str)", - "_args": { - "mask": "255.255.224.0", - }, + "_args": ["255.255.224.0"], "_results": { "__len__": 19, "__str__": "/19", @@ -233,9 +210,7 @@ }, { "_description": "Test the IPv4 mask: 255.255.255.0 (str)", - "_args": { - "mask": "255.255.255.0", - }, + "_args": ["255.255.255.0"], "_results": { "__len__": 24, "__str__": "/24", @@ -250,9 +225,7 @@ }, { "_description": "Test the IPv4 mask: 255.255.255.252 (str)", - "_args": { - "mask": "255.255.255.252", - }, + "_args": ["255.255.255.252"], "_results": { "__len__": 30, "__str__": "/30", @@ -267,9 +240,7 @@ }, { "_description": "Test the IPv4 mask: 255.255.255.255 (str)", - "_args": { - "mask": "255.255.255.255", - }, + "_args": ["255.255.255.255"], "_results": { "__len__": 32, "__str__": "/32", @@ -298,7 +269,7 @@ def setUp(self) -> None: Initialize the IPv4 mask object with testcase arguments. """ - self._ip4_mask = Ip4Mask(**self._args) + self._ip4_mask = Ip4Mask(*self._args) def test__net_addr__ip4_mask__len(self) -> None: """ @@ -414,11 +385,9 @@ def test__net_addr__ip4_mask__is_ip6(self) -> None: [ { "_description": "Test the IPv4 mask format: '255.255.255.256'", - "_args": { - "mask": "255.255.255.256", - }, + "_args": ["255.255.255.256"], "_results": { - "error": IpMaskFormatError, + "error": Ip4MaskFormatError, "error_message": ( "The IPv4 mask format is invalid: '255.255.255.256'" ), @@ -426,11 +395,9 @@ def test__net_addr__ip4_mask__is_ip6(self) -> None: }, { "_description": "Test the IPv4 mask format: '255.255.255,255'", - "_args": { - "mask": "255.255.255,255", - }, + "_args": ["255.255.255,255"], "_results": { - "error": IpMaskFormatError, + "error": Ip4MaskFormatError, "error_message": ( "The IPv4 mask format is invalid: '255.255.255,255'" ), @@ -438,11 +405,9 @@ def test__net_addr__ip4_mask__is_ip6(self) -> None: }, { "_description": "Test the IPv4 mask format: b'\xff\xff\xff'", - "_args": { - "mask": b"\xff\xff\xff", - }, + "_args": [b"\xff\xff\xff"], "_results": { - "error": IpMaskFormatError, + "error": Ip4MaskFormatError, "error_message": ( r"The IPv4 mask format is invalid: b'\xff\xff\xff'" ), @@ -450,11 +415,9 @@ def test__net_addr__ip4_mask__is_ip6(self) -> None: }, { "_description": "Test the IPv4 mask format: b'\xff\xff\xff\xff\xff'", - "_args": { - "mask": b"\xff\xff\xff\xff\xff", - }, + "_args": [b"\xff\xff\xff\xff\xff"], "_results": { - "error": IpMaskFormatError, + "error": Ip4MaskFormatError, "error_message": ( r"The IPv4 mask format is invalid: b'\xff\xff\xff\xff\xff'" ), @@ -462,26 +425,48 @@ def test__net_addr__ip4_mask__is_ip6(self) -> None: }, { "_description": "Test the IPv4 mask format: -1", - "_args": { - "mask": -1, - }, + "_args": [-1], "_results": { - "error": IpMaskFormatError, + "error": Ip4MaskFormatError, "error_message": ("The IPv4 mask format is invalid: -1"), }, }, { "_description": "Test the IPv4 mask format: 4294967296", - "_args": { - "mask": 4294967296, - }, + "_args": [4294967296], "_results": { - "error": IpMaskFormatError, + "error": Ip4MaskFormatError, "error_message": ( "The IPv4 mask format is invalid: 4294967296" ), }, }, + { + "_description": "Test the IPv4 mask format: Ip6Mask()", + "_args": [Ip6Mask()], + "_results": { + "error": Ip4MaskFormatError, + "error_message": ( + "The IPv4 mask format is invalid: Ip6Mask('::')" + ), + }, + }, + { + "_description": "Test the IPv4 mask format: {}", + "_args": [{}], + "_results": { + "error": Ip4MaskFormatError, + "error_message": "The IPv4 mask format is invalid: {}", + }, + }, + { + "_description": "Test the IPv4 address format: 1.1", + "_args": [1.1], + "_results": { + "error": Ip4MaskFormatError, + "error_message": "The IPv4 mask format is invalid: 1.1", + }, + }, ] ) class TestNetAddrIp4MaskErrors(TestCase): @@ -499,7 +484,7 @@ def test__net_addr__ip4_mask__errors(self) -> None: """ with self.assertRaises(self._results["error"]) as error: - Ip4Mask(**self._args) + Ip4Mask(*self._args) self.assertEqual( str(error.exception), diff --git a/tests/unit/lib/net_addr/test__ip6_address.py b/tests/unit/lib/net_addr/test__ip6_address.py index 60886b93..9ebebb7d 100644 --- a/tests/unit/lib/net_addr/test__ip6_address.py +++ b/tests/unit/lib/net_addr/test__ip6_address.py @@ -45,9 +45,7 @@ [ { "_description": "Test the IPv6 address: :: (str)", - "_args": { - "address": "::", - }, + "_args": ["::"], "_results": { "__str__": "::", "__repr__": "Ip6Address('::')", @@ -72,9 +70,7 @@ }, { "_description": "Test the IPv6 address: :: (None)", - "_args": { - "address": None, - }, + "_args": [None], "_results": { "__str__": "::", "__repr__": "Ip6Address('::')", @@ -99,9 +95,7 @@ }, { "_description": "Test the IPv6 address: ::1 (str)", - "_args": { - "address": "::1", - }, + "_args": ["::1"], "_results": { "__str__": "::1", "__repr__": "Ip6Address('::1')", @@ -126,9 +120,7 @@ }, { "_description": "Test the IPv6 address: 2000:: (str)", - "_args": { - "address": "2000::", - }, + "_args": ["2000::"], "_results": { "__str__": "2000::", "__repr__": "Ip6Address('2000::')", @@ -153,9 +145,7 @@ }, { "_description": "Test the IPv6 address: 3fff:ffff:ffff:ffff:ffff:ffff:ffff:ffff (str)", - "_args": { - "address": "3fff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", - }, + "_args": ["3fff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"], "_results": { "__str__": "3fff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", "__repr__": "Ip6Address('3fff:ffff:ffff:ffff:ffff:ffff:ffff:ffff')", @@ -182,9 +172,7 @@ }, { "_description": "Test the IPv6 address: fe80:: (str)", - "_args": { - "address": "fe80::", - }, + "_args": ["fe80::"], "_results": { "__str__": "fe80::", "__repr__": "Ip6Address('fe80::')", @@ -209,9 +197,7 @@ }, { "_description": "Test the IPv6 address: febf:ffff:ffff:ffff:ffff:ffff:ffff:ffff (str)", - "_args": { - "address": "febf:ffff:ffff:ffff:ffff:ffff:ffff:ffff", - }, + "_args": ["febf:ffff:ffff:ffff:ffff:ffff:ffff:ffff"], "_results": { "__str__": "febf:ffff:ffff:ffff:ffff:ffff:ffff:ffff", "__repr__": "Ip6Address('febf:ffff:ffff:ffff:ffff:ffff:ffff:ffff')", @@ -238,9 +224,7 @@ }, { "_description": "Test the IPv6 address: fc00:: (str)", - "_args": { - "address": "fc00::", - }, + "_args": ["fc00::"], "_results": { "__str__": "fc00::", "__repr__": "Ip6Address('fc00::')", @@ -265,9 +249,7 @@ }, { "_description": "Test the IPv6 address: fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff (str)", - "_args": { - "address": "fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", - }, + "_args": ["fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"], "_results": { "__str__": "fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", "__repr__": "Ip6Address('fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff')", @@ -294,9 +276,7 @@ }, { "_description": "Test the IPv6 address: ff00:: (str)", - "_args": { - "address": "ff00::", - }, + "_args": ["ff00::"], "_results": { "__str__": "ff00::", "__repr__": "Ip6Address('ff00::')", @@ -321,9 +301,7 @@ }, { "_description": "Test the IPv6 address: ff02::1 (str)", - "_args": { - "address": "ff02::1", - }, + "_args": ["ff02::1"], "_results": { "__str__": "ff02::1", "__repr__": "Ip6Address('ff02::1')", @@ -348,9 +326,7 @@ }, { "_description": "Test the IPv6 address: ff02::2 (str)", - "_args": { - "address": "ff02::2", - }, + "_args": ["ff02::2"], "_results": { "__str__": "ff02::2", "__repr__": "Ip6Address('ff02::2')", @@ -375,9 +351,7 @@ }, { "_description": "Test the IPv6 address: ff02::1:ff00:0 (str)", - "_args": { - "address": "ff02::1:ff00:0", - }, + "_args": ["ff02::1:ff00:0"], "_results": { "__str__": "ff02::1:ff00:0", "__repr__": "Ip6Address('ff02::1:ff00:0')", @@ -402,9 +376,7 @@ }, { "_description": "Test the IPv6 address: ff02::1:ff00:0 (str uppercase)", - "_args": { - "address": "FF02::1:FF00:0", - }, + "_args": ["FF02::1:FF00:0"], "_results": { "__str__": "ff02::1:ff00:0", "__repr__": "Ip6Address('ff02::1:ff00:0')", @@ -429,9 +401,7 @@ }, { "_description": "Test the IPv6 address: ff02::1:ff00:0 (Ip6Address)", - "_args": { - "address": Ip6Address("ff02::1:ff00:0"), - }, + "_args": [Ip6Address("ff02::1:ff00:0")], "_results": { "__str__": "ff02::1:ff00:0", "__repr__": "Ip6Address('ff02::1:ff00:0')", @@ -456,9 +426,7 @@ }, { "_description": "Test the IPv6 address: ff02::1:ff00:0 (int)", - "_args": { - "address": 338963523518870617245727861372719464448, - }, + "_args": [338963523518870617245727861372719464448], "_results": { "__str__": "ff02::1:ff00:0", "__repr__": "Ip6Address('ff02::1:ff00:0')", @@ -483,9 +451,9 @@ }, { "_description": "Test the IPv6 address: ff02::1:ff00:0 (bytes)", - "_args": { - "address": b"\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xff\x00\x00\x00", - }, + "_args": [ + b"\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xff\x00\x00\x00" + ], "_results": { "__str__": "ff02::1:ff00:0", "__repr__": "Ip6Address('ff02::1:ff00:0')", @@ -510,11 +478,11 @@ }, { "_description": "Test the IPv6 address: ff02::1:ff00:0 (bytearray)", - "_args": { - "address": bytearray( + "_args": [ + bytearray( b"\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xff\x00\x00\x00" - ), - }, + ) + ], "_results": { "__str__": "ff02::1:ff00:0", "__repr__": "Ip6Address('ff02::1:ff00:0')", @@ -539,11 +507,11 @@ }, { "_description": "Test the IPv6 address: ff02::1:ff00:0 (memoryview)", - "_args": { - "address": memoryview( + "_args": [ + memoryview( b"\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xff\x00\x00\x00" - ), - }, + ) + ], "_results": { "__str__": "ff02::1:ff00:0", "__repr__": "Ip6Address('ff02::1:ff00:0')", @@ -568,9 +536,7 @@ }, { "_description": "Test the IPv6 address: ff02::1:ffff:ffff (str)", - "_args": { - "address": "ff02::1:ffff:ffff", - }, + "_args": ["ff02::1:ffff:ffff"], "_results": { "__str__": "ff02::1:ffff:ffff", "__repr__": "Ip6Address('ff02::1:ffff:ffff')", @@ -595,9 +561,7 @@ }, { "_description": "Test the IPv6 address: ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff (str)", - "_args": { - "address": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", - }, + "_args": ["ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"], "_results": { "__str__": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", "__repr__": "Ip6Address('ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff')", @@ -638,7 +602,7 @@ def setUp(self) -> None: Initialize the IPv6 address object with testcase arguments. """ - self._ip6_address = Ip6Address(**self._args) + self._ip6_address = Ip6Address(*self._args) def test__net_addr__ip6_address__str(self) -> None: """ @@ -854,9 +818,7 @@ def test__net_addr__ip6_address__is_private(self) -> None: [ { "_description": "Test the IPv6 address format: '2000::10000'", - "_args": { - "address": "2000::10000", - }, + "_args": ["2000::10000"], "_results": { "error": Ip6AddressFormatError, "error_message": ( @@ -866,9 +828,7 @@ def test__net_addr__ip6_address__is_private(self) -> None: }, { "_description": "Test the IPv6 address format: '2000:::'", - "_args": { - "address": "2000:::", - }, + "_args": ["2000:::"], "_results": { "error": Ip6AddressFormatError, "error_message": ( @@ -878,9 +838,7 @@ def test__net_addr__ip6_address__is_private(self) -> None: }, { "_description": "Test the IPv6 address format: '2000;:1'", - "_args": { - "address": "2000;:1", - }, + "_args": ["2000;:1"], "_results": { "error": Ip6AddressFormatError, "error_message": ( @@ -893,9 +851,9 @@ def test__net_addr__ip6_address__is_private(self) -> None: "Test the IPv6 address format: " "b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'" ), - "_args": { - "address": b"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", - }, + "_args": [ + b"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" + ], "_results": { "error": Ip6AddressFormatError, "error_message": ( @@ -909,9 +867,9 @@ def test__net_addr__ip6_address__is_private(self) -> None: "Test the IPv6 address format: " "b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'" ), - "_args": { - "address": b"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", - }, + "_args": [ + b"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" + ], "_results": { "error": Ip6AddressFormatError, "error_message": ( @@ -922,9 +880,7 @@ def test__net_addr__ip6_address__is_private(self) -> None: }, { "_description": "Test the IPv6 address format: -1", - "_args": { - "address": -1, - }, + "_args": [-1], "_results": { "error": Ip6AddressFormatError, "error_message": ("The IPv6 address format is invalid: -1"), @@ -934,9 +890,7 @@ def test__net_addr__ip6_address__is_private(self) -> None: "_description": ( "Test the IPv6 address format: 340282366920938463463374607431768211456" ), - "_args": { - "address": 340282366920938463463374607431768211456, - }, + "_args": [340282366920938463463374607431768211456], "_results": { "error": Ip6AddressFormatError, "error_message": ( @@ -946,9 +900,7 @@ def test__net_addr__ip6_address__is_private(self) -> None: }, { "_description": "Test the IPv6 address format: Ip4Address()", - "_args": { - "address": Ip4Address(), - }, + "_args": [Ip4Address()], "_results": { "error": Ip6AddressFormatError, "error_message": "The IPv6 address format is invalid: Ip4Address('0.0.0.0')", @@ -956,9 +908,7 @@ def test__net_addr__ip6_address__is_private(self) -> None: }, { "_description": "Test the IPv6 address format: {}", - "_args": { - "address": {}, - }, + "_args": [{}], "_results": { "error": Ip6AddressFormatError, "error_message": "The IPv6 address format is invalid: {}", @@ -966,9 +916,7 @@ def test__net_addr__ip6_address__is_private(self) -> None: }, { "_description": "Test the IPv6 address format: 1.1", - "_args": { - "address": 1.1, - }, + "_args": [1.1], "_results": { "error": Ip6AddressFormatError, "error_message": "The IPv6 address format is invalid: 1.1", @@ -991,7 +939,7 @@ def test__net_addr__ip6_address__errors(self) -> None: """ with self.assertRaises(self._results["error"]) as error: - Ip6Address(**self._args) + Ip6Address(*self._args) self.assertEqual( str(error.exception), diff --git a/tests/unit/lib/net_addr/test__mac_address.py b/tests/unit/lib/net_addr/test__mac_address.py index a802645c..30373305 100644 --- a/tests/unit/lib/net_addr/test__mac_address.py +++ b/tests/unit/lib/net_addr/test__mac_address.py @@ -45,9 +45,7 @@ [ { "_description": "Test the MAC address: 00:00:00:00:00:00 (str)", - "_args": { - "address": "00:00:00:00:00:00", - }, + "_args": ["00:00:00:00:00:00"], "_results": { "__str__": "00:00:00:00:00:00", "__repr__": "MacAddress('00:00:00:00:00:00')", @@ -65,9 +63,7 @@ }, { "_description": "Test the MAC address: 00:00:00:00:00:00 (None)", - "_args": { - "address": None, - }, + "_args": [None], "_results": { "__str__": "00:00:00:00:00:00", "__repr__": "MacAddress('00:00:00:00:00:00')", @@ -85,9 +81,7 @@ }, { "_description": "Test the MAC address: 02:03:04:aa:bb:cc (str)", - "_args": { - "address": "02:03:04:aa:bb:cc", - }, + "_args": ["02:03:04:aa:bb:cc"], "_results": { "__str__": "02:03:04:aa:bb:cc", "__repr__": "MacAddress('02:03:04:aa:bb:cc')", @@ -105,9 +99,7 @@ }, { "_description": "Test the MAC address: 02:03:04:aa:bb:cc (str uppercase)", - "_args": { - "address": "02:03:04:AA:BB:CC", - }, + "_args": ["02:03:04:AA:BB:CC"], "_results": { "__str__": "02:03:04:aa:bb:cc", "__repr__": "MacAddress('02:03:04:aa:bb:cc')", @@ -125,9 +117,7 @@ }, { "_description": "Test the MAC address: 02:03:04:aa:bb:cc (bytes)", - "_args": { - "address": b"\x02\x03\x04\xaa\xbb\xcc", - }, + "_args": [b"\x02\x03\x04\xaa\xbb\xcc"], "_results": { "__str__": "02:03:04:aa:bb:cc", "__repr__": "MacAddress('02:03:04:aa:bb:cc')", @@ -145,9 +135,7 @@ }, { "_description": "Test the MAC address: 02:03:04:aa:bb:cc (bytearray)", - "_args": { - "address": bytearray(b"\x02\x03\x04\xaa\xbb\xcc"), - }, + "_args": [bytearray(b"\x02\x03\x04\xaa\xbb\xcc")], "_results": { "__str__": "02:03:04:aa:bb:cc", "__repr__": "MacAddress('02:03:04:aa:bb:cc')", @@ -165,9 +153,7 @@ }, { "_description": "Test the MAC address: 02:03:04:aa:bb:cc (memoryview)", - "_args": { - "address": memoryview(b"\x02\x03\x04\xaa\xbb\xcc"), - }, + "_args": [memoryview(b"\x02\x03\x04\xaa\xbb\xcc")], "_results": { "__str__": "02:03:04:aa:bb:cc", "__repr__": "MacAddress('02:03:04:aa:bb:cc')", @@ -185,9 +171,7 @@ }, { "_description": "Test the MAC address: 02:03:04:aa:bb:cc (MacAddress)", - "_args": { - "address": MacAddress("02:03:04:aa:bb:cc"), - }, + "_args": [MacAddress("02:03:04:aa:bb:cc")], "_results": { "__str__": "02:03:04:aa:bb:cc", "__repr__": "MacAddress('02:03:04:aa:bb:cc')", @@ -205,9 +189,7 @@ }, { "_description": "Test the MAC address: 02:03:04:aa:bb:cc (int)", - "_args": { - "address": 2211986455500, - }, + "_args": [2211986455500], "_results": { "__str__": "02:03:04:aa:bb:cc", "__repr__": "MacAddress('02:03:04:aa:bb:cc')", @@ -225,9 +207,7 @@ }, { "_description": "Test the MAC address: 01:00:5e:01:02:03 (str)", - "_args": { - "address": "01:00:5e:01:02:03", - }, + "_args": ["01:00:5e:01:02:03"], "_results": { "__str__": "01:00:5e:01:02:03", "__repr__": "MacAddress('01:00:5e:01:02:03')", @@ -245,9 +225,7 @@ }, { "_description": "Test the MAC address: 33:33:00:01:02:03 (str)", - "_args": { - "address": "33:33:00:01:02:03", - }, + "_args": ["33:33:00:01:02:03"], "_results": { "__str__": "33:33:00:01:02:03", "__repr__": "MacAddress('33:33:00:01:02:03')", @@ -265,9 +243,7 @@ }, { "_description": "Test the MAC address: 33:33:00:01:02:03 (str)", - "_args": { - "address": "33:33:00:01:02:03", - }, + "_args": ["33:33:00:01:02:03"], "_results": { "__str__": "33:33:00:01:02:03", "__repr__": "MacAddress('33:33:00:01:02:03')", @@ -285,9 +261,7 @@ }, { "_description": "Test the MAC address: 33:33:ff:01:02:03 (str)", - "_args": { - "address": "33:33:ff:01:02:03", - }, + "_args": ["33:33:ff:01:02:03"], "_results": { "__str__": "33:33:ff:01:02:03", "__repr__": "MacAddress('33:33:ff:01:02:03')", @@ -305,9 +279,7 @@ }, { "_description": "Test the MAC address: ff:ff:ff:ff:ff:ff (str)", - "_args": { - "address": "ff:ff:ff:ff:ff:ff", - }, + "_args": ["ff:ff:ff:ff:ff:ff"], "_results": { "__str__": "ff:ff:ff:ff:ff:ff", "__repr__": "MacAddress('ff:ff:ff:ff:ff:ff')", @@ -339,7 +311,7 @@ def setUp(self) -> None: Initialize the MAC address object with testcase arguments. """ - self._mac_address = MacAddress(**self._args) + self._mac_address = MacAddress(*self._args) def test__net_addr__mac_address__str(self) -> None: """ @@ -493,9 +465,7 @@ def test__net_addr__mac_address__is_broadcast(self) -> None: [ { "_description": "Test the MAC address format: '01:23:45:ab:cd'", - "_args": { - "address": "01:23:45:ab:cd", - }, + "_args": ["01:23:45:ab:cd"], "_results": { "error": MacAddressFormatError, "error_message": ( @@ -505,9 +475,7 @@ def test__net_addr__mac_address__is_broadcast(self) -> None: }, { "_description": "Test the MAC address format: '01:23:45:ab:cd:ef:01'", - "_args": { - "address": "01:23:45:ab:cd:ef:01", - }, + "_args": ["01:23:45:ab:cd:ef:01"], "_results": { "error": MacAddressFormatError, "error_message": ( @@ -517,9 +485,7 @@ def test__net_addr__mac_address__is_broadcast(self) -> None: }, { "_description": "Test the MAC address format: '01:23:45:ab:cd:eg'", - "_args": { - "address": "01:23:45:ab:cd:eg", - }, + "_args": ["01:23:45:ab:cd:eg"], "_results": { "error": MacAddressFormatError, "error_message": ( @@ -529,9 +495,7 @@ def test__net_addr__mac_address__is_broadcast(self) -> None: }, { "_description": "Test the MAC address format: b'\x01\x23\x45\xab\xcd'", - "_args": { - "address": b"\x01\x23\x45\xab\xcd", - }, + "_args": [b"\x01\x23\x45\xab\xcd"], "_results": { "error": MacAddressFormatError, "error_message": ( @@ -541,9 +505,7 @@ def test__net_addr__mac_address__is_broadcast(self) -> None: }, { "_description": "Test the MAC address format: b'\x01\x23\x45\xab\xcd\xef\x01'", - "_args": { - "address": b"\x01\x23\x45\xab\xcd\xef\x01", - }, + "_args": [b"\x01\x23\x45\xab\xcd\xef\x01"], "_results": { "error": MacAddressFormatError, "error_message": ( @@ -553,9 +515,7 @@ def test__net_addr__mac_address__is_broadcast(self) -> None: }, { "_description": "Test the MAC address format: -1", - "_args": { - "address": -1, - }, + "_args": [-1], "_results": { "error": MacAddressFormatError, "error_message": "The MAC address format is invalid: -1", @@ -563,9 +523,7 @@ def test__net_addr__mac_address__is_broadcast(self) -> None: }, { "_description": "Test the MAC address format: 281474976710656", - "_args": { - "address": 281474976710656, - }, + "_args": [281474976710656], "_results": { "error": MacAddressFormatError, "error_message": "The MAC address format is invalid: 281474976710656", @@ -573,9 +531,7 @@ def test__net_addr__mac_address__is_broadcast(self) -> None: }, { "_description": "Test the MAC address format: {}", - "_args": { - "address": {}, - }, + "_args": [{}], "_results": { "error": MacAddressFormatError, "error_message": "The MAC address format is invalid: {}", @@ -583,9 +539,7 @@ def test__net_addr__mac_address__is_broadcast(self) -> None: }, { "_description": "Test the MAC address format: 1.1", - "_args": { - "address": 1.1, - }, + "_args": [1.1], "_results": { "error": MacAddressFormatError, "error_message": "The MAC address format is invalid: 1.1", @@ -608,7 +562,7 @@ def test__net_addr__mac_address__errors(self) -> None: """ with self.assertRaises(self._results["error"]) as error: - MacAddress(**self._args) + MacAddress(*self._args) self.assertEqual( str(error.exception),