annotate Lib/test/test_socket_ssl.py @ 28646:193b8aec00ce legacy-trunk

Changes from Jonathan Riehl to allow his pgen extension (PEP 269) to work. This includes some more code that used to be part of pgen in the main parser; I'm okay with that. I'll see if the Windows build needs work next.
author Guido van Rossum <guido@python.org>
date Thu, 17 Apr 2003 14:55:42 +0000
parents 18dcf80e6f8d
children d0dc956467bf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19419
125785f1e12f A test of SSL support, using a roundabout method suggested by Guido.
Barry Warsaw <barry@python.org>
parents:
diff changeset
1 # Test just the SSL support in the socket module, in a moderately bogus way.
125785f1e12f A test of SSL support, using a roundabout method suggested by Guido.
Barry Warsaw <barry@python.org>
parents:
diff changeset
2
24364
aa0d2d51fbde Get rid of relative imports in all unittests. Now anything that
Barry Warsaw <barry@python.org>
parents: 20547
diff changeset
3 from test import test_support
26527
18dcf80e6f8d Rearrange test_socket_ssl so that a skip is expected iff the network
Tim Peters <tim.peters@gmail.com>
parents: 24364
diff changeset
4 import socket
19419
125785f1e12f A test of SSL support, using a roundabout method suggested by Guido.
Barry Warsaw <barry@python.org>
parents:
diff changeset
5
26527
18dcf80e6f8d Rearrange test_socket_ssl so that a skip is expected iff the network
Tim Peters <tim.peters@gmail.com>
parents: 24364
diff changeset
6 # Optionally test SSL support. This requires the 'network' resource as given
18dcf80e6f8d Rearrange test_socket_ssl so that a skip is expected iff the network
Tim Peters <tim.peters@gmail.com>
parents: 24364
diff changeset
7 # on the regrtest command line.
18dcf80e6f8d Rearrange test_socket_ssl so that a skip is expected iff the network
Tim Peters <tim.peters@gmail.com>
parents: 24364
diff changeset
8 skip_expected = not (test_support.is_resource_enabled('network') and
18dcf80e6f8d Rearrange test_socket_ssl so that a skip is expected iff the network
Tim Peters <tim.peters@gmail.com>
parents: 24364
diff changeset
9 hasattr(socket, "ssl"))
19419
125785f1e12f A test of SSL support, using a roundabout method suggested by Guido.
Barry Warsaw <barry@python.org>
parents:
diff changeset
10
26527
18dcf80e6f8d Rearrange test_socket_ssl so that a skip is expected iff the network
Tim Peters <tim.peters@gmail.com>
parents: 24364
diff changeset
11 def test_main():
18dcf80e6f8d Rearrange test_socket_ssl so that a skip is expected iff the network
Tim Peters <tim.peters@gmail.com>
parents: 24364
diff changeset
12 test_support.requires('network')
18dcf80e6f8d Rearrange test_socket_ssl so that a skip is expected iff the network
Tim Peters <tim.peters@gmail.com>
parents: 24364
diff changeset
13 if not hasattr(socket, "ssl"):
18dcf80e6f8d Rearrange test_socket_ssl so that a skip is expected iff the network
Tim Peters <tim.peters@gmail.com>
parents: 24364
diff changeset
14 raise test_support.TestSkipped("socket module has no ssl support")
19762
d09268d0ea52 Skip instead of fail this test if the socket module has no ssl
Guido van Rossum <guido@python.org>
parents: 19419
diff changeset
15
26527
18dcf80e6f8d Rearrange test_socket_ssl so that a skip is expected iff the network
Tim Peters <tim.peters@gmail.com>
parents: 24364
diff changeset
16 import urllib
19419
125785f1e12f A test of SSL support, using a roundabout method suggested by Guido.
Barry Warsaw <barry@python.org>
parents:
diff changeset
17
26527
18dcf80e6f8d Rearrange test_socket_ssl so that a skip is expected iff the network
Tim Peters <tim.peters@gmail.com>
parents: 24364
diff changeset
18 socket.RAND_status()
18dcf80e6f8d Rearrange test_socket_ssl so that a skip is expected iff the network
Tim Peters <tim.peters@gmail.com>
parents: 24364
diff changeset
19 try:
18dcf80e6f8d Rearrange test_socket_ssl so that a skip is expected iff the network
Tim Peters <tim.peters@gmail.com>
parents: 24364
diff changeset
20 socket.RAND_egd(1)
18dcf80e6f8d Rearrange test_socket_ssl so that a skip is expected iff the network
Tim Peters <tim.peters@gmail.com>
parents: 24364
diff changeset
21 except TypeError:
18dcf80e6f8d Rearrange test_socket_ssl so that a skip is expected iff the network
Tim Peters <tim.peters@gmail.com>
parents: 24364
diff changeset
22 pass
18dcf80e6f8d Rearrange test_socket_ssl so that a skip is expected iff the network
Tim Peters <tim.peters@gmail.com>
parents: 24364
diff changeset
23 else:
18dcf80e6f8d Rearrange test_socket_ssl so that a skip is expected iff the network
Tim Peters <tim.peters@gmail.com>
parents: 24364
diff changeset
24 print "didn't raise TypeError"
18dcf80e6f8d Rearrange test_socket_ssl so that a skip is expected iff the network
Tim Peters <tim.peters@gmail.com>
parents: 24364
diff changeset
25 socket.RAND_add("this is a random string", 75.0)
20506
97c75f981a9e Add trivial test cases for RAND_add() and RAND_status().
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19762
diff changeset
26
26527
18dcf80e6f8d Rearrange test_socket_ssl so that a skip is expected iff the network
Tim Peters <tim.peters@gmail.com>
parents: 24364
diff changeset
27 f = urllib.urlopen('https://sf.net')
18dcf80e6f8d Rearrange test_socket_ssl so that a skip is expected iff the network
Tim Peters <tim.peters@gmail.com>
parents: 24364
diff changeset
28 buf = f.read()
18dcf80e6f8d Rearrange test_socket_ssl so that a skip is expected iff the network
Tim Peters <tim.peters@gmail.com>
parents: 24364
diff changeset
29 f.close()
18dcf80e6f8d Rearrange test_socket_ssl so that a skip is expected iff the network
Tim Peters <tim.peters@gmail.com>
parents: 24364
diff changeset
30
18dcf80e6f8d Rearrange test_socket_ssl so that a skip is expected iff the network
Tim Peters <tim.peters@gmail.com>
parents: 24364
diff changeset
31 if __name__ == "__main__":
18dcf80e6f8d Rearrange test_socket_ssl so that a skip is expected iff the network
Tim Peters <tim.peters@gmail.com>
parents: 24364
diff changeset
32 test_main()