]> granicus.if.org Git - python/commitdiff
Issue #3583: mention that testing whether a bad address not triggering
authorBrett Cannon <brett@python.org>
Fri, 11 Jan 2013 16:17:53 +0000 (11:17 -0500)
committerBrett Cannon <brett@python.org>
Fri, 11 Jan 2013 16:17:53 +0000 (11:17 -0500)
an OSError can mean a bad DNS server and not an actual bug.

Lib/test/test_urllibnet.py

index e0782d2c516f70fda84d253deb1e7c78b91cbd0b..896d7c93e3cc1fd32eeb107c95bb45a2979eb7e4 100644 (file)
@@ -121,16 +121,15 @@ class urlopenNetworkTests(unittest.TestCase):
         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(OSError,
-                          # SF patch 809915:  In Sep 2003, VeriSign started
-                          # highjacking invalid .com and .net addresses to
-                          # boost traffic to their own site.  This test
-                          # started failing then.  One hopes the .invalid
-                          # domain will be spared to serve its defined
-                          # purpose.
-                          # urllib.urlopen, "http://www.sadflkjsasadf.com/")
-                          urllib.request.urlopen,
-                          "http://sadflkjsasf.i.nvali.d/")
+        failure_explanation = ('opening an invalid URL did not raise OSError; '
+                               'can be caused by a broken DNS server '
+                               '(e.g. returns 404 or hijacks page)')
+        with self.assertRaises(OSError, msg=failure_explanation):
+            # SF patch 809915:  In Sep 2003, VeriSign started highjacking
+            # invalid .com and .net addresses to boost traffic to their own
+            # site.  This test started failing then.  One hopes the .invalid
+            # domain will be spared to serve its defined purpose.
+            urllib.request.urlopen("http://sadflkjsasf.i.nvali.d/")
 
 
 class urlretrieveNetworkTests(unittest.TestCase):