summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_socket_ssl.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2002-12-04 03:26:57 (GMT)
committerTim Peters <tim.peters@gmail.com>2002-12-04 03:26:57 (GMT)
commitb4ee4eb3b308d55bd0d8d5a1abb2015950934c77 (patch)
tree38ed792399ecfdd3d04857ca7c90d63c63719485 /Lib/test/test_socket_ssl.py
parent6ee68d20b7b588e9b1438970b3d101fb04a8e65d (diff)
downloadcpython-b4ee4eb3b308d55bd0d8d5a1abb2015950934c77.zip
cpython-b4ee4eb3b308d55bd0d8d5a1abb2015950934c77.tar.gz
cpython-b4ee4eb3b308d55bd0d8d5a1abb2015950934c77.tar.bz2
Rearrange test_socket_ssl so that a skip is expected iff the network
resource isn't enabled or the socket module doesn't support ssl.
Diffstat (limited to 'Lib/test/test_socket_ssl.py')
-rw-r--r--Lib/test/test_socket_ssl.py43
1 files changed, 24 insertions, 19 deletions
diff --git a/Lib/test/test_socket_ssl.py b/Lib/test/test_socket_ssl.py
index 9c0d8cc..eb00b9b 100644
--- a/Lib/test/test_socket_ssl.py
+++ b/Lib/test/test_socket_ssl.py
@@ -1,27 +1,32 @@
# 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()