use pragma: no cover where appropriate

This commit is contained in:
Jack Robison 2020-11-01 15:19:27 -05:00
parent 1cfa5dd567
commit abca2a601b
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
5 changed files with 28 additions and 29 deletions

View file

@ -121,4 +121,4 @@ def main(argv: typing.Optional[typing.List[typing.Optional[str]]] = None,
if __name__ == "__main__": if __name__ == "__main__":
sys.exit(main()) sys.exit(main()) # pragma: no cover

View file

@ -200,7 +200,7 @@ class SOAPCommands:
"""Returns None""" """Returns None"""
name = "AddPortMapping" name = "AddPortMapping"
if not self.is_registered(name): if not self.is_registered(name):
raise NotImplementedError() raise NotImplementedError() # pragma: no cover
assert name in self._wrappers_kwargs assert name in self._wrappers_kwargs
await self._wrappers_kwargs[name]( await self._wrappers_kwargs[name](
NewRemoteHost=NewRemoteHost, NewExternalPort=NewExternalPort, NewProtocol=NewProtocol, NewRemoteHost=NewRemoteHost, NewExternalPort=NewExternalPort, NewProtocol=NewProtocol,
@ -216,7 +216,7 @@ class SOAPCommands:
""" """
name = "GetGenericPortMappingEntry" name = "GetGenericPortMappingEntry"
if not self.is_registered(name): if not self.is_registered(name):
raise NotImplementedError() raise NotImplementedError() # pragma: no cover
assert name in self._wrappers_kwargs assert name in self._wrappers_kwargs
result: GetGenericPortMappingEntryResponse = await self._wrappers_kwargs[name]( result: GetGenericPortMappingEntryResponse = await self._wrappers_kwargs[name](
NewPortMappingIndex=NewPortMappingIndex NewPortMappingIndex=NewPortMappingIndex
@ -228,7 +228,7 @@ class SOAPCommands:
"""Returns (NewInternalPort, NewInternalClient, NewEnabled, NewPortMappingDescription, NewLeaseDuration)""" """Returns (NewInternalPort, NewInternalClient, NewEnabled, NewPortMappingDescription, NewLeaseDuration)"""
name = "GetSpecificPortMappingEntry" name = "GetSpecificPortMappingEntry"
if not self.is_registered(name): if not self.is_registered(name):
raise NotImplementedError() raise NotImplementedError() # pragma: no cover
assert name in self._wrappers_kwargs assert name in self._wrappers_kwargs
result: GetSpecificPortMappingEntryResponse = await self._wrappers_kwargs[name]( result: GetSpecificPortMappingEntryResponse = await self._wrappers_kwargs[name](
NewRemoteHost=NewRemoteHost, NewExternalPort=NewExternalPort, NewProtocol=NewProtocol NewRemoteHost=NewRemoteHost, NewExternalPort=NewExternalPort, NewProtocol=NewProtocol
@ -239,7 +239,7 @@ class SOAPCommands:
"""Returns None""" """Returns None"""
name = "DeletePortMapping" name = "DeletePortMapping"
if not self.is_registered(name): if not self.is_registered(name):
raise NotImplementedError() raise NotImplementedError() # pragma: no cover
assert name in self._wrappers_kwargs assert name in self._wrappers_kwargs
await self._wrappers_kwargs[name]( await self._wrappers_kwargs[name](
NewRemoteHost=NewRemoteHost, NewExternalPort=NewExternalPort, NewProtocol=NewProtocol NewRemoteHost=NewRemoteHost, NewExternalPort=NewExternalPort, NewProtocol=NewProtocol
@ -250,7 +250,7 @@ class SOAPCommands:
"""Returns (NewExternalIPAddress)""" """Returns (NewExternalIPAddress)"""
name = "GetExternalIPAddress" name = "GetExternalIPAddress"
if not self.is_registered(name): if not self.is_registered(name):
raise NotImplementedError() raise NotImplementedError() # pragma: no cover
assert name in self._wrappers_no_args assert name in self._wrappers_no_args
result: str = await self._wrappers_no_args[name]() result: str = await self._wrappers_no_args[name]()
if not result: if not result:
@ -261,7 +261,7 @@ class SOAPCommands:
# """Returns (NewRSIPAvailable, NewNATEnabled)""" # """Returns (NewRSIPAvailable, NewNATEnabled)"""
# name = "GetNATRSIPStatus" # name = "GetNATRSIPStatus"
# if not self.is_registered(name): # if not self.is_registered(name):
# raise NotImplementedError() # raise NotImplementedError() # pragma: no cover
# assert name in self._wrappers_no_args # assert name in self._wrappers_no_args
# result: Tuple[bool, bool] = await self._wrappers_no_args[name]() # result: Tuple[bool, bool] = await self._wrappers_no_args[name]()
# return result[0], result[1] # return result[0], result[1]
@ -270,7 +270,7 @@ class SOAPCommands:
# """Returns None""" # """Returns None"""
# name = "SetConnectionType" # name = "SetConnectionType"
# if not self.is_registered(name): # if not self.is_registered(name):
# raise NotImplementedError() # raise NotImplementedError() # pragma: no cover
# assert name in self._wrappers_kwargs # assert name in self._wrappers_kwargs
# await self._wrappers_kwargs[name](NewConnectionType=NewConnectionType) # await self._wrappers_kwargs[name](NewConnectionType=NewConnectionType)
# return None # return None
@ -279,7 +279,7 @@ class SOAPCommands:
# """Returns (NewConnectionType, NewPossibleConnectionTypes)""" # """Returns (NewConnectionType, NewPossibleConnectionTypes)"""
# name = "GetConnectionTypeInfo" # name = "GetConnectionTypeInfo"
# if not self.is_registered(name): # if not self.is_registered(name):
# raise NotImplementedError() # raise NotImplementedError() # pragma: no cover
# assert name in self._wrappers_no_args # assert name in self._wrappers_no_args
# result: Tuple[str, str] = await self._wrappers_no_args[name]() # result: Tuple[str, str] = await self._wrappers_no_args[name]()
# return result # return result
@ -288,7 +288,7 @@ class SOAPCommands:
# """Returns (NewConnectionStatus, NewLastConnectionError, NewUptime)""" # """Returns (NewConnectionStatus, NewLastConnectionError, NewUptime)"""
# name = "GetStatusInfo" # name = "GetStatusInfo"
# if not self.is_registered(name): # if not self.is_registered(name):
# raise NotImplementedError() # raise NotImplementedError() # pragma: no cover
# assert name in self._wrappers_no_args # assert name in self._wrappers_no_args
# result: Tuple[str, str, int] = await self._wrappers_no_args[name]() # result: Tuple[str, str, int] = await self._wrappers_no_args[name]()
# return result # return result
@ -297,7 +297,7 @@ class SOAPCommands:
# """Returns None""" # """Returns None"""
# name = "ForceTermination" # name = "ForceTermination"
# if not self.is_registered(name): # if not self.is_registered(name):
# raise NotImplementedError() # raise NotImplementedError() # pragma: no cover
# assert name in self._wrappers_no_args # assert name in self._wrappers_no_args
# await self._wrappers_no_args[name]() # await self._wrappers_no_args[name]()
# return None # return None
@ -306,7 +306,7 @@ class SOAPCommands:
# """Returns None""" # """Returns None"""
# name = "RequestConnection" # name = "RequestConnection"
# if not self.is_registered(name): # if not self.is_registered(name):
# raise NotImplementedError() # raise NotImplementedError() # pragma: no cover
# assert name in self._wrappers_no_args # assert name in self._wrappers_no_args
# await self._wrappers_no_args[name]() # await self._wrappers_no_args[name]()
# return None # return None
@ -316,7 +316,7 @@ class SOAPCommands:
# NewPhysicalLinkStatus)""" # NewPhysicalLinkStatus)"""
# name = "GetCommonLinkProperties" # name = "GetCommonLinkProperties"
# if not self.is_registered(name): # if not self.is_registered(name):
# raise NotImplementedError() # raise NotImplementedError() # pragma: no cover
# assert name in self._wrappers_no_args # assert name in self._wrappers_no_args
# result: Tuple[str, int, int, str] = await self._wrappers_no_args[name]() # result: Tuple[str, int, int, str] = await self._wrappers_no_args[name]()
# return result # return result
@ -325,7 +325,7 @@ class SOAPCommands:
# """Returns (NewTotalBytesSent)""" # """Returns (NewTotalBytesSent)"""
# name = "GetTotalBytesSent" # name = "GetTotalBytesSent"
# if not self.is_registered(name): # if not self.is_registered(name):
# raise NotImplementedError() # raise NotImplementedError() # pragma: no cover
# assert name in self._wrappers_no_args # assert name in self._wrappers_no_args
# result: Tuple[int] = await self._wrappers_no_args[name]() # result: Tuple[int] = await self._wrappers_no_args[name]()
# return result[0] # return result[0]
@ -334,7 +334,7 @@ class SOAPCommands:
# """Returns (NewTotalBytesReceived)""" # """Returns (NewTotalBytesReceived)"""
# name = "GetTotalBytesReceived" # name = "GetTotalBytesReceived"
# if not self.is_registered(name): # if not self.is_registered(name):
# raise NotImplementedError() # raise NotImplementedError() # pragma: no cover
# assert name in self._wrappers_no_args # assert name in self._wrappers_no_args
# result: Tuple[int] = await self._wrappers_no_args[name]() # result: Tuple[int] = await self._wrappers_no_args[name]()
# return result[0] # return result[0]
@ -343,7 +343,7 @@ class SOAPCommands:
# """Returns (NewTotalPacketsSent)""" # """Returns (NewTotalPacketsSent)"""
# name = "GetTotalPacketsSent" # name = "GetTotalPacketsSent"
# if not self.is_registered(name): # if not self.is_registered(name):
# raise NotImplementedError() # raise NotImplementedError() # pragma: no cover
# assert name in self._wrappers_no_args # assert name in self._wrappers_no_args
# result: Tuple[int] = await self._wrappers_no_args[name]() # result: Tuple[int] = await self._wrappers_no_args[name]()
# return result[0] # return result[0]
@ -352,7 +352,7 @@ class SOAPCommands:
# """Returns (NewTotalPacketsReceived)""" # """Returns (NewTotalPacketsReceived)"""
# name = "GetTotalPacketsReceived" # name = "GetTotalPacketsReceived"
# if not self.is_registered(name): # if not self.is_registered(name):
# raise NotImplementedError() # raise NotImplementedError() # pragma: no cover
# assert name in self._wrappers_no_args # assert name in self._wrappers_no_args
# result: Tuple[int] = await self._wrappers_no_args[name]() # result: Tuple[int] = await self._wrappers_no_args[name]()
# return result[0] # return result[0]
@ -362,7 +362,7 @@ class SOAPCommands:
# Layer1DownstreamMaxBitRate, Uptime)""" # Layer1DownstreamMaxBitRate, Uptime)"""
# name = "X_GetICSStatistics" # name = "X_GetICSStatistics"
# if not self.is_registered(name): # if not self.is_registered(name):
# raise NotImplementedError() # raise NotImplementedError() # pragma: no cover
# assert name in self._wrappers_no_args # assert name in self._wrappers_no_args
# result: Tuple[int, int, int, int, str, str] = await self._wrappers_no_args[name]() # result: Tuple[int, int, int, int, str, str] = await self._wrappers_no_args[name]()
# return result # return result
@ -371,7 +371,7 @@ class SOAPCommands:
# """Returns (NewDefaultConnectionService)""" # """Returns (NewDefaultConnectionService)"""
# name = "GetDefaultConnectionService" # name = "GetDefaultConnectionService"
# if not self.is_registered(name): # if not self.is_registered(name):
# raise NotImplementedError() # raise NotImplementedError() # pragma: no cover
# assert name in self._wrappers_no_args # assert name in self._wrappers_no_args
# result: Tuple[str] = await self._wrappers_no_args[name]() # result: Tuple[str] = await self._wrappers_no_args[name]()
# return result[0] # return result[0]
@ -380,7 +380,7 @@ class SOAPCommands:
# """Returns (None)""" # """Returns (None)"""
# name = "SetDefaultConnectionService" # name = "SetDefaultConnectionService"
# if not self.is_registered(name): # if not self.is_registered(name):
# raise NotImplementedError() # raise NotImplementedError() # pragma: no cover
# assert name in self._wrappers_kwargs # assert name in self._wrappers_kwargs
# await self._wrappers_kwargs[name](NewDefaultConnectionService=NewDefaultConnectionService) # await self._wrappers_kwargs[name](NewDefaultConnectionService=NewDefaultConnectionService)
# return None # return None
@ -388,7 +388,7 @@ class SOAPCommands:
# async def SetEnabledForInternet(self, NewEnabledForInternet: bool) -> None: # async def SetEnabledForInternet(self, NewEnabledForInternet: bool) -> None:
# name = "SetEnabledForInternet" # name = "SetEnabledForInternet"
# if not self.is_registered(name): # if not self.is_registered(name):
# raise NotImplementedError() # raise NotImplementedError() # pragma: no cover
# assert name in self._wrappers_kwargs # assert name in self._wrappers_kwargs
# await self._wrappers_kwargs[name](NewEnabledForInternet=NewEnabledForInternet) # await self._wrappers_kwargs[name](NewEnabledForInternet=NewEnabledForInternet)
# return None # return None
@ -396,7 +396,7 @@ class SOAPCommands:
# async def GetEnabledForInternet(self) -> bool: # async def GetEnabledForInternet(self) -> bool:
# name = "GetEnabledForInternet" # name = "GetEnabledForInternet"
# if not self.is_registered(name): # if not self.is_registered(name):
# raise NotImplementedError() # raise NotImplementedError() # pragma: no cover
# assert name in self._wrappers_no_args # assert name in self._wrappers_no_args
# result: Tuple[bool] = await self._wrappers_no_args[name]() # result: Tuple[bool] = await self._wrappers_no_args[name]()
# return result[0] # return result[0]
@ -404,7 +404,7 @@ class SOAPCommands:
# async def GetMaximumActiveConnections(self, NewActiveConnectionIndex: int) -> None: # async def GetMaximumActiveConnections(self, NewActiveConnectionIndex: int) -> None:
# name = "GetMaximumActiveConnections" # name = "GetMaximumActiveConnections"
# if not self.is_registered(name): # if not self.is_registered(name):
# raise NotImplementedError() # raise NotImplementedError() # pragma: no cover
# assert name in self._wrappers_kwargs # assert name in self._wrappers_kwargs
# await self._wrappers_kwargs[name](NewActiveConnectionIndex=NewActiveConnectionIndex) # await self._wrappers_kwargs[name](NewActiveConnectionIndex=NewActiveConnectionIndex)
# return None # return None
@ -413,7 +413,7 @@ class SOAPCommands:
# """Returns (NewActiveConnDeviceContainer, NewActiveConnectionServiceID""" # """Returns (NewActiveConnDeviceContainer, NewActiveConnectionServiceID"""
# name = "GetActiveConnections" # name = "GetActiveConnections"
# if not self.is_registered(name): # if not self.is_registered(name):
# raise NotImplementedError() # raise NotImplementedError() # pragma: no cover
# assert name in self._wrappers_no_args # assert name in self._wrappers_no_args
# result: Tuple[str, str] = await self._wrappers_no_args[name]() # result: Tuple[str, str] = await self._wrappers_no_args[name]()
# return result # return result

View file

@ -5,7 +5,7 @@ import netifaces
from aioupnp.fault import UPnPError from aioupnp.fault import UPnPError
def get_netifaces(): def get_netifaces(): # pragma: no cover
return netifaces return netifaces

View file

@ -7,11 +7,10 @@ from asyncio.transports import DatagramTransport
from unittest import mock from unittest import mock
if sys.version_info >= (3, 8): SOCKET_TYPES = (socket.SocketType, mock.MagicMock)
if sys.version_info >= (3, 8): # pragma: no cover
from asyncio.trsock import TransportSocket from asyncio.trsock import TransportSocket
SOCKET_TYPES = (socket.SocketType, TransportSocket, mock.MagicMock) SOCKET_TYPES = (socket.SocketType, TransportSocket, mock.MagicMock)
else:
SOCKET_TYPES = (socket.SocketType, mock.MagicMock)
def _get_sock(transport: typing.Optional[DatagramTransport]) -> typing.Optional[socket.socket]: def _get_sock(transport: typing.Optional[DatagramTransport]) -> typing.Optional[socket.socket]:

View file

@ -37,7 +37,7 @@ class UPnP:
return cls.delete_port_mapping.__annotations__, cls.delete_port_mapping.__doc__ return cls.delete_port_mapping.__annotations__, cls.delete_port_mapping.__doc__
if command == "get_next_mapping": if command == "get_next_mapping":
return cls.get_next_mapping.__annotations__, cls.get_next_mapping.__doc__ return cls.get_next_mapping.__annotations__, cls.get_next_mapping.__doc__
raise AttributeError(command) raise AttributeError(command) # pragma: no cover
@staticmethod @staticmethod
def get_lan_and_gateway(lan_address: str = '', gateway_address: str = '', def get_lan_and_gateway(lan_address: str = '', gateway_address: str = '',