[Python-checkins] cpython (merge 3.2 -> default): Avoid failing in test_urllibnet.test_bad_address when some overzealous

antoine.pitrou python-checkins at python.org
Fri Jul 8 19:23:28 CEST 2011


http://hg.python.org/cpython/rev/99d20a3e3c29
changeset:   71259:99d20a3e3c29
parent:      71256:4120cd8a86f4
parent:      71258:6adab7448272
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Fri Jul 08 19:22:31 2011 +0200
summary:
  Avoid failing in test_urllibnet.test_bad_address when some overzealous
DNS service (e.g. OpenDNS) resolves a non-existent domain name.  The test
is now skipped instead.

files:
  Lib/test/test_urllibnet.py |  8 ++++++++
  Misc/NEWS                  |  4 ++++
  2 files changed, 12 insertions(+), 0 deletions(-)


diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py
--- a/Lib/test/test_urllibnet.py
+++ b/Lib/test/test_urllibnet.py
@@ -113,6 +113,14 @@
     def test_bad_address(self):
         # Make sure proper exception is raised when connecting to a bogus
         # address.
+        bogus_domain = "sadflkjsasf.i.nvali.d"
+        try:
+            socket.gethostbyname(bogus_domain)
+        except socket.gaierror:
+            pass
+        else:
+            # This happens with some overzealous DNS providers such as OpenDNS
+            self.skipTest("%r should not resolve for test to work" % bogus_domain)
         self.assertRaises(IOError,
                           # SF patch 809915:  In Sep 2003, VeriSign started
                           # highjacking invalid .com and .net addresses to
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -1004,6 +1004,10 @@
 Tests
 -----
 
+- Avoid failing in test_urllibnet.test_bad_address when some overzealous
+  DNS service (e.g. OpenDNS) resolves a non-existent domain name.  The test
+  is now skipped instead.
+
 - Issue #12440: When testing whether some bits in SSLContext.options can be
   reset, check the version of the OpenSSL headers Python was compiled against,
   rather than the runtime version of the OpenSSL library.

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list