]> granicus.if.org Git - python/commitdiff
Let test_ssl fail gracefully if ssl support is not available
authorAntoine Pitrou <solipsis@pitrou.net>
Wed, 13 Oct 2010 11:38:36 +0000 (11:38 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Wed, 13 Oct 2010 11:38:36 +0000 (11:38 +0000)
Lib/test/test_ssl.py

index ca74e7132e7a5c8466ea40232f0dafd03a431c5e..0c8a8e63b297f72b33a4dcc801a2916e020f1091 100644 (file)
@@ -18,17 +18,12 @@ import weakref
 import platform
 import functools
 
-# Optionally test SSL support, if we have it in the tested platform
-skip_expected = False
-try:
-    import ssl
-except ImportError:
-    skip_expected = True
-else:
-    PROTOCOLS = [
-        ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv3,
-        ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1
-    ]
+ssl = support.import_module("ssl")
+
+PROTOCOLS = [
+    ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv3,
+    ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1
+]
 
 HOST = support.HOST
 
@@ -1489,9 +1484,6 @@ else:
 
 
 def test_main(verbose=False):
-    if skip_expected:
-        raise unittest.SkipTest("No SSL support")
-
     if support.verbose:
         plats = {
             'Linux': platform.linux_distribution,