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
4bf42749
Commit
4bf42749
authored
Feb 19, 2016
by
Martin Panter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #26309: Rewrite test in main thread and avoid race condition
parent
3fe64d0c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
24 deletions
+21
-24
Lib/test/test_socketserver.py
Lib/test/test_socketserver.py
+21
-24
No files found.
Lib/test/test_socketserver.py
View file @
4bf42749
...
...
@@ -280,30 +280,6 @@ class SocketServerTest(unittest.TestCase):
socketserver
.
TCPServer
((
HOST
,
-
1
),
socketserver
.
StreamRequestHandler
)
def
test_shutdown_request_called_if_verify_request_false
(
self
):
# Issue #26309: BaseServer should call shutdown_request even if
# verify_request is False
shutdown_called
=
False
class
MyServer
(
socketserver
.
TCPServer
):
def
verify_request
(
self
,
request
,
client_address
):
return
False
def
shutdown_request
(
self
,
request
):
nonlocal
shutdown_called
shutdown_called
=
True
super
().
shutdown_request
(
request
)
def
connect_to_server
(
proto
,
addr
):
s
=
socket
.
socket
(
proto
,
socket
.
SOCK_STREAM
)
s
.
connect
(
addr
)
s
.
close
()
self
.
run_server
(
MyServer
,
socketserver
.
StreamRequestHandler
,
connect_to_server
)
self
.
assertEqual
(
shutdown_called
,
True
)
class
MiscTestCase
(
unittest
.
TestCase
):
...
...
@@ -317,6 +293,27 @@ class MiscTestCase(unittest.TestCase):
expected
.
append
(
name
)
self
.
assertCountEqual
(
socketserver
.
__all__
,
expected
)
def
test_shutdown_request_called_if_verify_request_false
(
self
):
# Issue #26309: BaseServer should call shutdown_request even if
# verify_request is False
class
MyServer
(
socketserver
.
TCPServer
):
def
verify_request
(
self
,
request
,
client_address
):
return
False
shutdown_called
=
0
def
shutdown_request
(
self
,
request
):
self
.
shutdown_called
+=
1
socketserver
.
TCPServer
.
shutdown_request
(
self
,
request
)
server
=
MyServer
((
HOST
,
0
),
socketserver
.
StreamRequestHandler
)
s
=
socket
.
socket
(
server
.
address_family
,
socket
.
SOCK_STREAM
)
s
.
connect
(
server
.
server_address
)
s
.
close
()
server
.
handle_request
()
self
.
assertEqual
(
server
.
shutdown_called
,
1
)
server
.
server_close
()
if
__name__
==
"__main__"
:
unittest
.
main
()
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