Skip to content

Commit

Permalink
add tests indicating timeouts does not really work
Browse files Browse the repository at this point in the history
  • Loading branch information
Snawoot authored and saghul committed Oct 16, 2023
1 parent 40cb14c commit 14a55e4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import unittest
import socket
import sys
import time

import aiodns

Expand Down Expand Up @@ -101,10 +102,13 @@ def test_query_timeout(self):
self.resolver = aiodns.DNSResolver(timeout=0.1, loop=self.loop)
self.resolver.nameservers = ['1.2.3.4']
f = self.resolver.query('google.com', 'A')
started = time.monotonic()
try:
self.loop.run_until_complete(f)
except aiodns.error.DNSError as e:
self.assertEqual(e.args[0], aiodns.error.ARES_ETIMEOUT)
# Ensure timeout really cuts time deadline. Limit duration to one second
self.assertLess(time.monotonic() - started, 1)

def test_query_cancel(self):
f = self.resolver.query('google.com', 'A')
Expand Down

0 comments on commit 14a55e4

Please sign in to comment.