diff options
author | Bob Halley <halley@dnspython.org> | 2020-06-19 07:15:08 -0700 |
---|---|---|
committer | Bob Halley <halley@dnspython.org> | 2020-06-19 07:15:08 -0700 |
commit | 117349d3a58533e21258d312c11ca8b5aeefc82c (patch) | |
tree | 28ba15924fd98a90e9333609acd327e06175b48f | |
parent | e73aa1bf03d2f6660b5a77399528fbf4de57ef42 (diff) | |
download | dnspython-117349d3a58533e21258d312c11ca8b5aeefc82c.tar.gz |
improve async coverage
-rw-r--r-- | tests/test_async.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/test_async.py b/tests/test_async.py index 42f4c69..0e1913e 100644 --- a/tests/test_async.py +++ b/tests/test_async.py @@ -342,6 +342,28 @@ class AsyncTests(unittest.TestCase): (_, tcp) = self.async_run(run) self.assertFalse(tcp) + def testUDPReceiveTimeout(self): + async def arun(): + async with await self.backend.make_socket(socket.AF_INET, + socket.SOCK_DGRAM) as s: + try: + # for basic coverage + await s.getpeername() + except Exception: + # we expect failure as we haven't connected the socket + pass + await s.recvfrom(1000, 0.05) + def run(): + self.async_run(arun) + self.assertRaises(dns.exception.Timeout, run) + + def testSleep(self): + async def run(): + before = time.time() + self.backend.sleep(0.1) + after = time.time() + self.assertTrue(after - before >= 0.1) + try: import trio import sniffio |