mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
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.
This commit is contained in:
parent
6ee68d20b7
commit
b4ee4eb3b3
3 changed files with 36 additions and 29 deletions
|
|
@ -1,27 +1,32 @@
|
|||
# Test just the SSL support in the socket module, in a moderately bogus way.
|
||||
|
||||
from test import test_support
|
||||
|
||||
# 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')
|
||||
|
||||
import socket
|
||||
if not hasattr(socket, "ssl"):
|
||||
raise test_support.TestSkipped("socket module has no ssl support")
|
||||
|
||||
import urllib
|
||||
# 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"))
|
||||
|
||||
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)
|
||||
def test_main():
|
||||
test_support.requires('network')
|
||||
if not hasattr(socket, "ssl"):
|
||||
raise test_support.TestSkipped("socket module has no ssl support")
|
||||
|
||||
f = urllib.urlopen('https://sf.net')
|
||||
buf = f.read()
|
||||
f.close()
|
||||
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)
|
||||
|
||||
f = urllib.urlopen('https://sf.net')
|
||||
buf = f.read()
|
||||
f.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue