]> granicus.if.org Git - python/commitdiff
Issue #12012: test_ssl uses test_support.import_module()
authorVictor Stinner <victor.stinner@haypocalc.com>
Sun, 22 May 2011 11:22:28 +0000 (13:22 +0200)
committerVictor Stinner <victor.stinner@haypocalc.com>
Sun, 22 May 2011 11:22:28 +0000 (13:22 +0200)
Skip the whole file if the SSL module is missing. It was already the case,
except that the SkipTest exception was raised in test_main().

This commit fixes an error in test_ssl if the ssl module is missing.

Lib/test/test_ssl.py

index be2f51acaf62621e719548198ab80b9dc77742f7..3df4d0c34ced6f99b0ce60ce5bc8f066589c70d8 100644 (file)
@@ -20,12 +20,7 @@ import platform
 from BaseHTTPServer import HTTPServer
 from SimpleHTTPServer import SimpleHTTPRequestHandler
 
-# Optionally test SSL support, if we have it in the tested platform
-skip_expected = False
-try:
-    import ssl
-except ImportError:
-    skip_expected = True
+ssl = test_support.import_module("ssl")
 
 HOST = test_support.HOST
 CERTFILE = None
@@ -1334,9 +1329,6 @@ else:
 
 
 def test_main(verbose=False):
-    if skip_expected:
-        raise unittest.SkipTest("No SSL support")
-
     global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT
     CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir,
                             "keycert.pem")