Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
e6f68324
Commit
e6f68324
authored
Feb 08, 2010
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test__socket_timeout.py
parent
ef3e7bf8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
greentest/test__socket_timeout.py
greentest/test__socket_timeout.py
+37
-0
No files found.
greentest/test__socket_timeout.py
0 → 100644
View file @
e6f68324
import
gevent
from
gevent
import
socket
import
unittest
class
Test
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
server
=
socket
.
socket
()
self
.
server
.
bind
((
'127.0.0.1'
,
0
))
self
.
server
.
listen
(
1
)
self
.
server_port
=
self
.
server
.
getsockname
()[
1
]
self
.
acceptor
=
gevent
.
spawn
(
self
.
server
.
accept
)
def
tearDown
(
self
):
self
.
server
.
close
()
self
.
acceptor
.
kill
(
block
=
True
)
del
self
.
acceptor
del
self
.
server
def
test
(
self
):
sock
=
socket
.
socket
()
sock
.
connect
((
'127.0.0.1'
,
self
.
server_port
))
try
:
sock
.
settimeout
(
0.1
)
try
:
result
=
sock
.
recv
(
1024
)
raise
AssertionError
(
'Expected timeout to be raised, instead recv() returned %r'
%
(
result
,
))
except
socket
.
error
,
ex
:
self
.
assertEqual
(
ex
.
args
,
(
'timed out'
,))
self
.
assertEqual
(
str
(
ex
),
'timed out'
)
self
.
assertEqual
(
ex
[
0
],
'timed out'
)
finally
:
sock
.
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