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
0a1245f8
Commit
0a1245f8
authored
Jul 25, 2007
by
Nick Coghlan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More buildbot cleanup - let the OS assign the port for test_urllib2_localnet
parent
48ddfd62
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
29 deletions
+11
-29
Lib/test/test_urllib2_localnet.py
Lib/test/test_urllib2_localnet.py
+11
-29
No files found.
Lib/test/test_urllib2_localnet.py
View file @
0a1245f8
...
...
@@ -40,14 +40,16 @@ class LoopbackHttpServer(BaseHTTPServer.HTTPServer):
class
LoopbackHttpServerThread
(
threading
.
Thread
):
"""Stoppable thread that runs a loopback http server."""
def
__init__
(
self
,
port
,
RequestHandlerClass
):
def
__init__
(
self
,
request_handler
):
threading
.
Thread
.
__init__
(
self
)
self
.
_RequestHandlerClass
=
RequestHandlerClass
self
.
_stop
=
False
self
.
_port
=
port
self
.
_server_address
=
(
'127.0.0.1'
,
self
.
_port
)
self
.
ready
=
threading
.
Event
()
self
.
error
=
None
request_handler
.
protocol_version
=
"HTTP/1.0"
self
.
httpd
=
LoopbackHttpServer
((
'127.0.0.1'
,
0
),
request_handler
)
#print "Serving HTTP on %s port %s" % (self.httpd.server_name,
# self.httpd.server_port)
self
.
port
=
self
.
httpd
.
server_port
def
stop
(
self
):
"""Stops the webserver if it's currently running."""
...
...
@@ -58,24 +60,9 @@ class LoopbackHttpServerThread(threading.Thread):
self
.
join
()
def
run
(
self
):
protocol
=
"HTTP/1.0"
try
:
self
.
_RequestHandlerClass
.
protocol_version
=
protocol
httpd
=
LoopbackHttpServer
(
self
.
_server_address
,
self
.
_RequestHandlerClass
)
sa
=
httpd
.
socket
.
getsockname
()
#print "Serving HTTP on", sa[0], "port", sa[1], "..."
except
:
# Fail "gracefully" if we are unable to start.
self
.
ready
.
set
()
self
.
error
=
sys
.
exc_info
()[
1
]
raise
self
.
ready
.
set
()
while
not
self
.
_stop
:
httpd
.
handle_request
()
self
.
httpd
.
handle_request
()
# Authentication infrastructure
...
...
@@ -232,26 +219,21 @@ class FakeProxyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
class
ProxyAuthTests
(
unittest
.
TestCase
):
URL
=
"http://www.foo.com"
PORT
=
8080
USER
=
"tester"
PASSWD
=
"test123"
REALM
=
"TestRealm"
PROXY_URL
=
"http://127.0.0.1:%d"
%
PORT
def
setUp
(
self
):
FakeProxyHandler
.
digest_auth_handler
.
set_users
({
self
.
USER
:
self
.
PASSWD
})
FakeProxyHandler
.
digest_auth_handler
.
set_realm
(
self
.
REALM
)
self
.
server
=
LoopbackHttpServerThread
(
self
.
PORT
,
FakeProxyHandler
)
self
.
server
=
LoopbackHttpServerThread
(
FakeProxyHandler
)
self
.
server
.
start
()
self
.
server
.
ready
.
wait
()
if
self
.
server
.
error
:
raise
self
.
server
.
error
handler
=
urllib2
.
ProxyHandler
({
"http"
:
self
.
PROXY_URL
})
proxy_url
=
"http://127.0.0.1:%d"
%
self
.
server
.
port
handler
=
urllib2
.
ProxyHandler
({
"http"
:
proxy_url
})
self
.
_digest_auth_handler
=
urllib2
.
ProxyDigestAuthHandler
()
self
.
opener
=
urllib2
.
build_opener
(
handler
,
self
.
_digest_auth_handler
)
...
...
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