]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
improve async coverage
authorBob Halley <halley@dnspython.org>
Fri, 19 Jun 2020 14:14:28 +0000 (07:14 -0700)
committerBob Halley <halley@dnspython.org>
Fri, 19 Jun 2020 14:14:28 +0000 (07:14 -0700)
dns/_asyncio_backend.py
dns/_curio_backend.py
dns/_trio_backend.py

index f82eb823916363091f3d53e7f206e6a7934494ce..4120624d409fac4a9fe2b5734400f8df4a704fb9 100644 (file)
@@ -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)
index d5eba68d8e54ba4494a2c3c78445a65849beb690..dca966df56865e4a9dbe235376a0b87c433e2a7d 100644 (file)
@@ -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)
index cfb0e1d18aad7f911c54428a85ae14d0d8906f31..0f1378f319b2a05c917f0d89f06527e3c47cfcfd 100644 (file)
@@ -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)