Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
150acda5
Commit
150acda5
authored
Apr 27, 2010
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove uses of find_unused_port() in test_ssl, and small cleanups
parent
47b5440f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
19 deletions
+17
-19
Lib/test/test_ssl.py
Lib/test/test_ssl.py
+17
-19
No files found.
Lib/test/test_ssl.py
View file @
150acda5
...
@@ -696,9 +696,9 @@ else:
...
@@ -696,9 +696,9 @@ else:
self
.
flag
=
None
self
.
flag
=
None
self
.
active
=
False
self
.
active
=
False
self
.
RootedHTTPRequestHandler
.
root
=
os
.
path
.
split
(
CERTFILE
)[
0
]
self
.
RootedHTTPRequestHandler
.
root
=
os
.
path
.
split
(
CERTFILE
)[
0
]
self
.
port
=
test_support
.
find_unused_port
()
self
.
server
=
self
.
HTTPSServer
(
self
.
server
=
self
.
HTTPSServer
(
(
HOST
,
self
.
port
),
self
.
RootedHTTPRequestHandler
,
certfile
)
(
HOST
,
0
),
self
.
RootedHTTPRequestHandler
,
certfile
)
self
.
port
=
self
.
server
.
server_port
threading
.
Thread
.
__init__
(
self
)
threading
.
Thread
.
__init__
(
self
)
self
.
daemon
=
True
self
.
daemon
=
True
...
@@ -851,28 +851,28 @@ else:
...
@@ -851,28 +851,28 @@ else:
listener_ready
=
threading
.
Event
()
listener_ready
=
threading
.
Event
()
listener_gone
=
threading
.
Event
()
listener_gone
=
threading
.
Event
()
port
=
test_support
.
find_unused_port
()
# `listener` runs in a thread. It opens a socket listening on
s
=
socket
.
socket
()
# PORT, and sits in an accept() until the main thread connects.
port
=
test_support
.
bind_port
(
s
,
HOST
)
# Then it rudely closes the socket, and sets Event `listener_gone`
# to let the main thread know the socket is gone.
# `listener` runs in a thread. It sits in an accept() until
# the main thread connects. Then it rudely closes the socket,
# and sets Event `listener_gone` to let the main thread know
# the socket is gone.
def
listener
():
def
listener
():
s
=
socket
.
socket
()
s
.
bind
((
HOST
,
port
))
s
.
listen
(
5
)
s
.
listen
(
5
)
listener_ready
.
set
()
listener_ready
.
set
()
s
.
accept
()
s
.
accept
()
s
=
None
# reclaim the socket object, which also closes it
s
.
close
()
listener_gone
.
set
()
listener_gone
.
set
()
def
connector
():
def
connector
():
listener_ready
.
wait
()
listener_ready
.
wait
()
s
=
socket
.
socket
()
c
=
socket
.
socket
()
s
.
connect
((
HOST
,
port
))
c
.
connect
((
HOST
,
port
))
listener_gone
.
wait
()
listener_gone
.
wait
()
try
:
try
:
ssl_sock
=
ssl
.
wrap_socket
(
s
)
ssl_sock
=
ssl
.
wrap_socket
(
c
)
except
IOError
:
except
IOError
:
pass
pass
else
:
else
:
...
@@ -881,8 +881,10 @@ else:
...
@@ -881,8 +881,10 @@ else:
t
=
threading
.
Thread
(
target
=
listener
)
t
=
threading
.
Thread
(
target
=
listener
)
t
.
start
()
t
.
start
()
connector
()
try
:
t
.
join
()
connector
()
finally
:
t
.
join
()
def
testEcho
(
self
):
def
testEcho
(
self
):
...
@@ -1354,10 +1356,6 @@ def test_main(verbose=False):
...
@@ -1354,10 +1356,6 @@ def test_main(verbose=False):
not
os
.
path
.
exists
(
SVN_PYTHON_ORG_ROOT_CERT
)):
not
os
.
path
.
exists
(
SVN_PYTHON_ORG_ROOT_CERT
)):
raise
test_support
.
TestFailed
(
"Can't read certificate files!"
)
raise
test_support
.
TestFailed
(
"Can't read certificate files!"
)
TESTPORT
=
test_support
.
find_unused_port
()
if
not
TESTPORT
:
raise
test_support
.
TestFailed
(
"Can't find open port to test servers on!"
)
tests
=
[
BasicTests
]
tests
=
[
BasicTests
]
if
test_support
.
is_resource_enabled
(
'network'
):
if
test_support
.
is_resource_enabled
(
'network'
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment