Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_socket_ssl.py @ 25838:8540887bcec6 2.2
Backport of 2.183:
Fix memory leak in add_subclass() found by NealN with valgrind.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 18 Oct 2002 13:42:21 +0000 |
| parents | a12ccdbce8da |
| children | aa0d2d51fbde |
| 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 |
|
125785f1e12f
A test of SSL support, using a roundabout method suggested by Guido.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
3 import test_support |
|
125785f1e12f
A test of SSL support, using a roundabout method suggested by Guido.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
4 |
|
125785f1e12f
A test of SSL support, using a roundabout method suggested by Guido.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
5 # Optionally test SSL support. This currently requires the 'network' resource |
|
125785f1e12f
A test of SSL support, using a roundabout method suggested by Guido.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
6 # as given on the regrtest command line. If not available, nothing after this |
|
125785f1e12f
A test of SSL support, using a roundabout method suggested by Guido.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
7 # line will be executed. |
|
125785f1e12f
A test of SSL support, using a roundabout method suggested by Guido.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
8 test_support.requires('network') |
|
125785f1e12f
A test of SSL support, using a roundabout method suggested by Guido.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
9 |
|
125785f1e12f
A test of SSL support, using a roundabout method suggested by Guido.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
10 import socket |
|
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
|
11 if not hasattr(socket, "ssl"): |
|
d09268d0ea52
Skip instead of fail this test if the socket module has no ssl
Guido van Rossum <guido@python.org>
parents:
19419
diff
changeset
|
12 raise test_support.TestSkipped("socket module has no ssl support") |
|
d09268d0ea52
Skip instead of fail this test if the socket module has no ssl
Guido van Rossum <guido@python.org>
parents:
19419
diff
changeset
|
13 |
|
19419
125785f1e12f
A test of SSL support, using a roundabout method suggested by Guido.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
14 import urllib |
|
125785f1e12f
A test of SSL support, using a roundabout method suggested by Guido.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
15 |
|
20506
97c75f981a9e
Add trivial test cases for RAND_add() and RAND_status().
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
19762
diff
changeset
|
16 socket.RAND_status() |
|
97c75f981a9e
Add trivial test cases for RAND_add() and RAND_status().
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
19762
diff
changeset
|
17 try: |
|
97c75f981a9e
Add trivial test cases for RAND_add() and RAND_status().
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
19762
diff
changeset
|
18 socket.RAND_egd(1) |
|
97c75f981a9e
Add trivial test cases for RAND_add() and RAND_status().
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
19762
diff
changeset
|
19 except TypeError: |
|
97c75f981a9e
Add trivial test cases for RAND_add() and RAND_status().
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
19762
diff
changeset
|
20 pass |
|
97c75f981a9e
Add trivial test cases for RAND_add() and RAND_status().
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
19762
diff
changeset
|
21 else: |
|
97c75f981a9e
Add trivial test cases for RAND_add() and RAND_status().
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
19762
diff
changeset
|
22 print "didn't raise TypeError" |
|
97c75f981a9e
Add trivial test cases for RAND_add() and RAND_status().
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
19762
diff
changeset
|
23 socket.RAND_add("this is a random string", 75.0) |
|
97c75f981a9e
Add trivial test cases for RAND_add() and RAND_status().
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
19762
diff
changeset
|
24 |
|
97c75f981a9e
Add trivial test cases for RAND_add() and RAND_status().
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
19762
diff
changeset
|
25 f = urllib.urlopen('https://sf.net') |
|
97c75f981a9e
Add trivial test cases for RAND_add() and RAND_status().
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
19762
diff
changeset
|
26 buf = f.read() |
|
97c75f981a9e
Add trivial test cases for RAND_add() and RAND_status().
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
19762
diff
changeset
|
27 f.close() |
