mirror of
https://github.com/python/cpython.git
synced 2025-11-13 15:40:05 +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
|
|
@ -534,6 +534,9 @@ def printlist(x, width=70, indent=4):
|
||||||
# Whether a skip is expected here depends on whether a large test
|
# Whether a skip is expected here depends on whether a large test
|
||||||
# input file has been downloaded. test_normalization.skip_expected
|
# input file has been downloaded. test_normalization.skip_expected
|
||||||
# controls that.
|
# controls that.
|
||||||
|
# test_socket_ssl
|
||||||
|
# Controlled by test_socket_ssl.skip_expected. Requires the network
|
||||||
|
# resource, and a socket module with ssl support.
|
||||||
|
|
||||||
_expectations = {
|
_expectations = {
|
||||||
'win32':
|
'win32':
|
||||||
|
|
@ -565,7 +568,6 @@ _expectations = {
|
||||||
test_pwd
|
test_pwd
|
||||||
test_resource
|
test_resource
|
||||||
test_signal
|
test_signal
|
||||||
test_socket_ssl
|
|
||||||
test_socketserver
|
test_socketserver
|
||||||
test_sunaudiodev
|
test_sunaudiodev
|
||||||
test_timing
|
test_timing
|
||||||
|
|
@ -583,7 +585,6 @@ _expectations = {
|
||||||
test_largefile
|
test_largefile
|
||||||
test_nis
|
test_nis
|
||||||
test_ntpath
|
test_ntpath
|
||||||
test_socket_ssl
|
|
||||||
test_socketserver
|
test_socketserver
|
||||||
test_sunaudiodev
|
test_sunaudiodev
|
||||||
test_unicode_file
|
test_unicode_file
|
||||||
|
|
@ -618,7 +619,6 @@ _expectations = {
|
||||||
test_pty
|
test_pty
|
||||||
test_pwd
|
test_pwd
|
||||||
test_signal
|
test_signal
|
||||||
test_socket_ssl
|
|
||||||
test_socketserver
|
test_socketserver
|
||||||
test_sunaudiodev
|
test_sunaudiodev
|
||||||
test_sundry
|
test_sundry
|
||||||
|
|
@ -736,7 +736,6 @@ _expectations = {
|
||||||
test_popen2
|
test_popen2
|
||||||
test_pty
|
test_pty
|
||||||
test_pwd
|
test_pwd
|
||||||
test_socket_ssl
|
|
||||||
test_socketserver
|
test_socketserver
|
||||||
test_strop
|
test_strop
|
||||||
test_sunaudiodev
|
test_sunaudiodev
|
||||||
|
|
@ -769,7 +768,6 @@ _expectations = {
|
||||||
test_nis
|
test_nis
|
||||||
test_ntpath
|
test_ntpath
|
||||||
test_poll
|
test_poll
|
||||||
test_socket_ssl
|
|
||||||
test_socketserver
|
test_socketserver
|
||||||
test_sunaudiodev
|
test_sunaudiodev
|
||||||
test_unicode_file
|
test_unicode_file
|
||||||
|
|
@ -792,7 +790,6 @@ _expectations = {
|
||||||
test_linuxaudiodev
|
test_linuxaudiodev
|
||||||
test_mpz
|
test_mpz
|
||||||
test_openpty
|
test_openpty
|
||||||
test_socket_ssl
|
|
||||||
test_socketserver
|
test_socketserver
|
||||||
test_winreg
|
test_winreg
|
||||||
test_winsound
|
test_winsound
|
||||||
|
|
@ -820,7 +817,6 @@ _expectations = {
|
||||||
test_openpty
|
test_openpty
|
||||||
test_pyexpat
|
test_pyexpat
|
||||||
test_sax
|
test_sax
|
||||||
test_socket_ssl
|
|
||||||
test_socketserver
|
test_socketserver
|
||||||
test_sunaudiodev
|
test_sunaudiodev
|
||||||
test_unicode_file
|
test_unicode_file
|
||||||
|
|
@ -850,7 +846,6 @@ _expectations = {
|
||||||
test_poll
|
test_poll
|
||||||
test_popen2
|
test_popen2
|
||||||
test_resource
|
test_resource
|
||||||
test_socket_ssl
|
|
||||||
test_socketserver
|
test_socketserver
|
||||||
test_sunaudiodev
|
test_sunaudiodev
|
||||||
test_unicode_file
|
test_unicode_file
|
||||||
|
|
@ -863,6 +858,7 @@ class _ExpectedSkips:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
import os.path
|
import os.path
|
||||||
from test import test_normalization
|
from test import test_normalization
|
||||||
|
from test import test_socket_ssl
|
||||||
|
|
||||||
self.valid = False
|
self.valid = False
|
||||||
if sys.platform in _expectations:
|
if sys.platform in _expectations:
|
||||||
|
|
@ -875,6 +871,9 @@ class _ExpectedSkips:
|
||||||
if test_normalization.skip_expected:
|
if test_normalization.skip_expected:
|
||||||
self.expected.add('test_normalization')
|
self.expected.add('test_normalization')
|
||||||
|
|
||||||
|
if test_socket_ssl.skip_expected:
|
||||||
|
self.expected.add('test_socket_ssl')
|
||||||
|
|
||||||
self.valid = True
|
self.valid = True
|
||||||
|
|
||||||
def isvalid(self):
|
def isvalid(self):
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,32 @@
|
||||||
# Test just the SSL support in the socket module, in a moderately bogus way.
|
# Test just the SSL support in the socket module, in a moderately bogus way.
|
||||||
|
|
||||||
from test import test_support
|
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
|
import socket
|
||||||
if not hasattr(socket, "ssl"):
|
|
||||||
|
# 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"))
|
||||||
|
|
||||||
|
def test_main():
|
||||||
|
test_support.requires('network')
|
||||||
|
if not hasattr(socket, "ssl"):
|
||||||
raise test_support.TestSkipped("socket module has no ssl support")
|
raise test_support.TestSkipped("socket module has no ssl support")
|
||||||
|
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
socket.RAND_status()
|
socket.RAND_status()
|
||||||
try:
|
try:
|
||||||
socket.RAND_egd(1)
|
socket.RAND_egd(1)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
print "didn't raise TypeError"
|
print "didn't raise TypeError"
|
||||||
socket.RAND_add("this is a random string", 75.0)
|
socket.RAND_add("this is a random string", 75.0)
|
||||||
|
|
||||||
f = urllib.urlopen('https://sf.net')
|
f = urllib.urlopen('https://sf.net')
|
||||||
buf = f.read()
|
buf = f.read()
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
test_main()
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,11 @@ def forget(modname):
|
||||||
except os.error:
|
except os.error:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def is_resource_enabled(resource):
|
||||||
|
return use_resources is not None and resource in use_resources
|
||||||
|
|
||||||
def requires(resource, msg=None):
|
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:
|
if msg is None:
|
||||||
msg = "Use of the `%s' resource not enabled" % resource
|
msg = "Use of the `%s' resource not enabled" % resource
|
||||||
raise TestSkipped(msg)
|
raise TestSkipped(msg)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue