diff options
| author | Bob Halley <halley@dnspython.org> | 2021-12-07 06:01:35 -0800 |
|---|---|---|
| committer | Bob Halley <halley@dnspython.org> | 2021-12-07 06:01:35 -0800 |
| commit | 911c317912cbe05f4b36da0289eec571ad8883cc (patch) | |
| tree | 003981d27b869b9e6573665175d9c28d101be2cb | |
| parent | 169520239516f66add7fb6e6a34183accc1ae265 (diff) | |
| download | dnspython-911c317912cbe05f4b36da0289eec571ad8883cc.tar.gz | |
cope with 3.6 exception difference
| -rw-r--r-- | tests/test_doh.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tests/test_doh.py b/tests/test_doh.py index 9dc4cec..6be7d21 100644 --- a/tests/test_doh.py +++ b/tests/test_doh.py @@ -17,6 +17,11 @@ import unittest import random import socket +try: + import ssl + _have_ssl = True +except Exception: + _have_ssl = False import dns.message import dns.query @@ -144,7 +149,7 @@ class DNSOverHTTPSTestCaseRequests(unittest.TestCase): self.assertTrue('8.8.4.4' in seen) -@unittest.skipUnless(dns.query._have_httpx and _network_available, +@unittest.skipUnless(dns.query._have_httpx and _network_available and _have_ssl, "Python httpx cannot be imported; no DNS over HTTPS (DOH)") class DNSOverHTTPSTestCaseHttpx(unittest.TestCase): def setUp(self): @@ -206,8 +211,9 @@ class DNSOverHTTPSTestCaseHttpx(unittest.TestCase): valid_tls_url = 'https://doh.cleanbrowsing.org/doh/family-filter/' q = dns.message.make_query('example.com.', dns.rdatatype.A) # make sure CleanBrowsing's IP address will fail TLS certificate - # check - with self.assertRaises(httpx.ConnectError): + # check. On 3.6 we get ssl.CertificateError instead of + # httpx.ConnectError. + with self.assertRaises((httpx.ConnectError, ssl.CertificateError)): dns.query.https(q, invalid_tls_url, session=self.session, timeout=4) # We can't do the Host header and SNI magic with httpx, but |
