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
f28cb38c
Commit
f28cb38c
authored
Sep 28, 2009
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add GenericGetTestCase
parent
b47db2d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
9 deletions
+49
-9
greentest/__init__.py
greentest/__init__.py
+49
-9
No files found.
greentest/__init__.py
View file @
f28cb38c
...
...
@@ -95,25 +95,65 @@ class CountingHub(_original_Hub):
gevent
.
hub
.
Hub
=
CountingHub
def
test_outer_timeout_is_not_lost
(
self
):
t
=
gevent
.
Timeout
.
start_new
(
0.01
)
try
:
self
.
wait
(
timeout
=
0.02
)
except
gevent
.
Timeout
,
ex
:
assert
ex
is
t
,
(
ex
,
t
)
else
:
raise
AssertionError
(
'must raise Timeout'
)
gevent
.
sleep
(
0.02
)
class
GenericWaitTestCase
(
TestCase
):
def
wait
(
self
,
timeout
):
raise
NotImplementedError
(
'override me in subclass'
)
def
test_outer_timeout_is_not_lost
(
self
):
t
=
gevent
.
Timeout
.
start_new
(
0.01
)
test_outer_timeout_is_not_lost
=
test_outer_timeout_is_not_lost
def
test_returns_none_after_timeout
(
self
):
start
=
time
.
time
()
result
=
self
.
wait
(
timeout
=
0.01
)
# join and wait simply returns after timeout expires
delay
=
time
.
time
()
-
start
assert
0.01
<=
delay
<
0.01
+
0.01
,
delay
assert
result
is
None
,
repr
(
result
)
class
GenericGetTestCase
(
TestCase
):
def
wait
(
self
,
timeout
):
raise
NotImplementedError
(
'override me in subclass'
)
test_outer_timeout_is_not_lost
=
test_outer_timeout_is_not_lost
def
test_raises_timeout_number
(
self
):
start
=
time
.
time
()
self
.
assertRaises
(
gevent
.
Timeout
,
self
.
wait
,
timeout
=
0.01
)
# get raises Timeout after timeout expired
delay
=
time
.
time
()
-
start
assert
0.01
<=
delay
<
0.01
+
0.01
,
delay
def
test_raises_timeout_Timeout
(
self
):
start
=
time
.
time
()
t
=
gevent
.
Timeout
(
0.01
)
try
:
self
.
wait
(
timeout
=
0.02
)
self
.
wait
(
timeout
=
t
)
except
gevent
.
Timeout
,
ex
:
assert
ex
is
t
,
(
ex
,
t
)
else
:
raise
AssertionError
(
'must raise Timeout'
)
gevent
.
sleep
(
0.02
)
delay
=
time
.
time
()
-
start
assert
0.01
<=
delay
<
0.01
+
0.01
,
delay
def
test_r
eturns_after_timeout
(
self
):
def
test_r
aises_timeout_Timeout_exc_customized
(
self
):
start
=
time
.
time
()
self
.
wait
(
timeout
=
0.01
)
# join simply returns after timeout expires
error
=
RuntimeError
(
'expected error'
)
t
=
gevent
.
Timeout
(
0.01
,
exception
=
error
)
try
:
self
.
wait
(
timeout
=
t
)
except
RuntimeError
,
ex
:
assert
ex
is
error
,
(
ex
,
error
)
delay
=
time
.
time
()
-
start
assert
0.01
<=
delay
<
0.01
+
0.01
,
delay
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