summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2020-06-19 07:14:28 -0700
committerBob Halley <halley@dnspython.org>2020-06-19 07:14:28 -0700
commitf256b9d9a980110049fd64280df36654d7ef05a9 (patch)
tree5bfcee85ab72061ae2bef60f2d8a48ba9e52fc51
parent6251e124c4ce3d4f37d13851e78c28b2db6c4257 (diff)
downloaddnspython-f256b9d9a980110049fd64280df36654d7ef05a9.tar.gz
improve async coverage
-rw-r--r--dns/_asyncio_backend.py5
-rw-r--r--dns/_curio_backend.py7
-rw-r--r--dns/_trio_backend.py9
3 files changed, 12 insertions, 9 deletions
diff --git a/dns/_asyncio_backend.py b/dns/_asyncio_backend.py
index f82eb82..4120624 100644
--- a/dns/_asyncio_backend.py
+++ b/dns/_asyncio_backend.py
@@ -57,7 +57,7 @@ class DatagramSocket(dns._asyncbackend.DatagramSocket):
self.transport = transport
self.protocol = protocol
- async def sendto(self, what, destination, timeout):
+ async def sendto(self, what, destination, timeout): # pragma: no cover
# no timeout for asyncio sendto
self.transport.sendto(what, destination)
@@ -127,7 +127,8 @@ class Backend(dns._asyncbackend.Backend):
server_hostname=server_hostname),
timeout)
return StreamSocket(af, r, w)
- raise NotImplementedError(f'unsupported socket type {socktype}')
+ raise NotImplementedError('unsupported socket ' +
+ f'type {socktype}') # pragma: no cover
async def sleep(self, interval):
await asyncio.sleep(interval)
diff --git a/dns/_curio_backend.py b/dns/_curio_backend.py
index d5eba68..dca966d 100644
--- a/dns/_curio_backend.py
+++ b/dns/_curio_backend.py
@@ -30,7 +30,7 @@ class DatagramSocket(dns._asyncbackend.DatagramSocket):
async def sendto(self, what, destination, timeout):
async with _maybe_timeout(timeout):
return await self.socket.sendto(what, destination)
- raise dns.exception.Timeout(timeout=timeout)
+ raise dns.exception.Timeout(timeout=timeout) # pragma: no cover
async def recvfrom(self, size, timeout):
async with _maybe_timeout(timeout):
@@ -78,7 +78,7 @@ class Backend(dns._asyncbackend.Backend):
try:
if source:
s.bind(_lltuple(source, af))
- except Exception:
+ except Exception: # pragma: no cover
await s.close()
raise
return DatagramSocket(s)
@@ -93,7 +93,8 @@ class Backend(dns._asyncbackend.Backend):
source_addr=source_addr,
server_hostname=server_hostname)
return StreamSocket(s)
- raise NotImplementedError(f'unsupported socket type {socktype}')
+ raise NotImplementedError('unsupported socket ' +
+ f'type {socktype}') # pragma: no cover
async def sleep(self, interval):
await curio.sleep(interval)
diff --git a/dns/_trio_backend.py b/dns/_trio_backend.py
index cfb0e1d..0f1378f 100644
--- a/dns/_trio_backend.py
+++ b/dns/_trio_backend.py
@@ -30,7 +30,7 @@ class DatagramSocket(dns._asyncbackend.DatagramSocket):
async def sendto(self, what, destination, timeout):
with _maybe_timeout(timeout):
return await self.socket.sendto(what, destination)
- raise dns.exception.Timeout(timeout=timeout)
+ raise dns.exception.Timeout(timeout=timeout) # pragma: no cover
async def recvfrom(self, size, timeout):
with _maybe_timeout(timeout):
@@ -85,7 +85,7 @@ class Backend(dns._asyncbackend.Backend):
if socktype == socket.SOCK_STREAM:
with _maybe_timeout(timeout):
await s.connect(_lltuple(destination, af))
- except Exception:
+ except Exception: # pragma: no cover
s.close()
raise
if socktype == socket.SOCK_DGRAM:
@@ -99,11 +99,12 @@ class Backend(dns._asyncbackend.Backend):
try:
stream = trio.SSLStream(stream, ssl_context,
server_hostname=server_hostname)
- except Exception:
+ except Exception: # pragma: no cover
await stream.aclose()
raise
return StreamSocket(af, stream, tls)
- raise NotImplementedError(f'unsupported socket type {socktype}')
+ raise NotImplementedError('unsupported socket ' +
+ f'type {socktype}') # pragma: no cover
async def sleep(self, interval):
await trio.sleep(interval)