Merged revisions 84650 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r84650 | antoine.pitrou | 2010-09-09 15:31:46 +0200 (jeu., 09 sept. 2010) | 4 lines

  Use transient_internet() where appropriate in test_ssl
  (svn.python.org is sometimes unavailable)
........
This commit is contained in:
Antoine Pitrou 2010-09-09 13:33:33 +00:00
parent f77342076e
commit 78d8946d19
1 changed files with 80 additions and 82 deletions

View File

@ -103,14 +103,9 @@ class BasicTests(unittest.TestCase):
class NetworkedTests(unittest.TestCase):
def setUp(self):
self.old_timeout = socket.getdefaulttimeout()
socket.setdefaulttimeout(30)
def tearDown(self):
socket.setdefaulttimeout(self.old_timeout)
def test_connect(self):
with support.transient_internet("svn.python.org"):
s = ssl.wrap_socket(socket.socket(socket.AF_INET),
cert_reqs=ssl.CERT_NONE)
s.connect(("svn.python.org", 443))
@ -143,6 +138,7 @@ class NetworkedTests(unittest.TestCase):
# Issue #5238: creating a file-like object with makefile() shouldn't
# delay closing the underlying "real socket" (here tested with its
# file descriptor, hence skipping the test under Windows).
with support.transient_internet("svn.python.org"):
ss = ssl.wrap_socket(socket.socket(socket.AF_INET))
ss.connect(("svn.python.org", 443))
fd = ss.fileno()
@ -161,6 +157,7 @@ class NetworkedTests(unittest.TestCase):
self.fail("OSError wasn't raised")
def test_non_blocking_handshake(self):
with support.transient_internet("svn.python.org"):
s = socket.socket(socket.AF_INET)
s.connect(("svn.python.org", 443))
s.setblocking(False)
@ -185,6 +182,7 @@ class NetworkedTests(unittest.TestCase):
sys.stdout.write("\nNeeded %d calls to do_handshake() to establish session.\n" % count)
def test_get_server_certificate(self):
with support.transient_internet("svn.python.org"):
pem = ssl.get_server_certificate(("svn.python.org", 443))
if not pem:
self.fail("No server certificate on svn.python.org:443!")