# Whether a skip is expected here depends on whether a large test
# input file has been downloaded. test_normalization.skip_expected
# controls that.
+# test_socket_ssl
+# Controlled by test_socket_ssl.skip_expected. Requires the network
+# resource, and a socket module with ssl support.
_expectations = {
'win32':
test_pwd
test_resource
test_signal
- test_socket_ssl
test_socketserver
test_sunaudiodev
test_timing
test_largefile
test_nis
test_ntpath
- test_socket_ssl
test_socketserver
test_sunaudiodev
test_unicode_file
test_pty
test_pwd
test_signal
- test_socket_ssl
test_socketserver
test_sunaudiodev
test_sundry
test_popen2
test_pty
test_pwd
- test_socket_ssl
test_socketserver
test_strop
test_sunaudiodev
test_nis
test_ntpath
test_poll
- test_socket_ssl
test_socketserver
test_sunaudiodev
test_unicode_file
test_linuxaudiodev
test_mpz
test_openpty
- test_socket_ssl
test_socketserver
test_winreg
test_winsound
test_openpty
test_pyexpat
test_sax
- test_socket_ssl
test_socketserver
test_sunaudiodev
test_unicode_file
test_poll
test_popen2
test_resource
- test_socket_ssl
test_socketserver
test_sunaudiodev
test_unicode_file
def __init__(self):
import os.path
from test import test_normalization
+ from test import test_socket_ssl
self.valid = False
if sys.platform in _expectations:
if test_normalization.skip_expected:
self.expected.add('test_normalization')
+ if test_socket_ssl.skip_expected:
+ self.expected.add('test_socket_ssl')
+
self.valid = True
def isvalid(self):
# Test just the SSL support in the socket module, in a moderately bogus way.
from test import test_support
+import socket
-# Optionally test SSL support. This currently requires the 'network' resource
-# as given on the regrtest command line. If not available, nothing after this
-# line will be executed.
-test_support.requires('network')
+# Optionally test SSL support. This requires the 'network' resource as given
+# on the regrtest command line.
+skip_expected = not (test_support.is_resource_enabled('network') and
+ hasattr(socket, "ssl"))
-import socket
-if not hasattr(socket, "ssl"):
- raise test_support.TestSkipped("socket module has no ssl support")
+def test_main():
+ test_support.requires('network')
+ if not hasattr(socket, "ssl"):
+ raise test_support.TestSkipped("socket module has no ssl support")
+
+ import urllib
-import urllib
+ socket.RAND_status()
+ try:
+ socket.RAND_egd(1)
+ except TypeError:
+ pass
+ else:
+ print "didn't raise TypeError"
+ socket.RAND_add("this is a random string", 75.0)
-socket.RAND_status()
-try:
- socket.RAND_egd(1)
-except TypeError:
- pass
-else:
- print "didn't raise TypeError"
-socket.RAND_add("this is a random string", 75.0)
+ f = urllib.urlopen('https://sf.net')
+ buf = f.read()
+ f.close()
-f = urllib.urlopen('https://sf.net')
-buf = f.read()
-f.close()
+if __name__ == "__main__":
+ test_main()
except os.error:
pass
+def is_resource_enabled(resource):
+ return use_resources is not None and resource in use_resources
+
def requires(resource, msg=None):
- if use_resources is not None and resource not in use_resources:
+ if not is_resource_enabled(resource):
if msg is None:
msg = "Use of the `%s' resource not enabled" % resource
raise TestSkipped(msg)