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
29c984ed
Commit
29c984ed
authored
Jul 21, 2009
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update the existing test to work with the new Timeout
parent
631d7761
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
16 deletions
+20
-16
greentest/coros_test.py
greentest/coros_test.py
+2
-2
greentest/test__api.py
greentest/test__api.py
+1
-1
greentest/test__api_timeout.py
greentest/test__api_timeout.py
+11
-7
greentest/test__coros_queue.py
greentest/test__coros_queue.py
+3
-3
greentest/test__proc.py
greentest/test__proc.py
+3
-3
No files found.
greentest/coros_test.py
View file @
29c984ed
...
...
@@ -87,8 +87,8 @@ class TestEvent(TestCase):
self
.
assertRaises
(
RuntimeError
,
evt
.
wait
)
evt
.
reset
()
# shouldn't see the RuntimeError again
gevent
.
Timeout
(
0.001
,
gevent
.
Timeout
Error
(
'from test_double_exception'
))
self
.
assertRaises
(
gevent
.
Timeout
Error
,
evt
.
wait
)
gevent
.
Timeout
(
0.001
,
Value
Error
(
'from test_double_exception'
))
self
.
assertRaises
(
Value
Error
,
evt
.
wait
)
if
__name__
==
'__main__'
:
...
...
greentest/test__api.py
View file @
29c984ed
...
...
@@ -48,7 +48,7 @@ class Test(greentest.TestCase):
def
test_nested_with_timeout
(
self
):
def
func
():
return
gevent
.
with_timeout
(
0.2
,
gevent
.
sleep
,
2
,
timeout_value
=
1
)
self
.
assertRaises
(
gevent
.
Timeout
Error
,
gevent
.
with_timeout
,
0.1
,
func
)
self
.
assertRaises
(
gevent
.
Timeout
,
gevent
.
with_timeout
,
0.1
,
func
)
class
TestTimers
(
greentest
.
TestCase
):
...
...
greentest/test__api_timeout.py
View file @
29c984ed
...
...
@@ -24,7 +24,7 @@ import sys
import
greentest
import
weakref
import
time
from
gevent
import
sleep
,
Timeout
,
TimeoutError
from
gevent
import
sleep
,
Timeout
from
gevent.greenlet
import
_SilentException
DELAY
=
0.04
...
...
@@ -35,18 +35,22 @@ class Test(greentest.TestCase):
def
test_api
(
self
):
# Nothing happens if with-block finishes before the timeout expires
with
Timeout
(
DELAY
*
2
):
t
=
Timeout
(
DELAY
*
2
)
assert
t
.
pending
,
repr
(
t
)
with
t
:
sleep
(
DELAY
)
sleep
(
DELAY
*
2
)
# check if timer was actually cancelled
# check if timer was actually cancelled
assert
not
t
.
pending
,
repr
(
t
)
sleep
(
DELAY
*
2
)
# An exception will be raised if it's not
try
:
with
Timeout
(
DELAY
):
with
Timeout
(
DELAY
)
as
t
:
sleep
(
DELAY
*
2
)
except
Timeout
Error
:
pass
except
Timeout
,
ex
:
assert
ex
is
t
,
(
ex
,
t
)
else
:
raise
AssertionError
(
'must raise Timeout
Error
'
)
raise
AssertionError
(
'must raise Timeout'
)
# You can customize the exception raised:
try
:
...
...
greentest/test__coros_queue.py
View file @
29c984ed
...
...
@@ -21,7 +21,7 @@ class TestQueue(TestCase):
def
test_send_last
(
self
):
q
=
coros
.
Queue
()
def
waiter
(
q
):
timer
=
gevent
.
Timeout
(
0.1
,
gevent
.
TimeoutError
)
timer
=
gevent
.
Timeout
(
0.1
)
self
.
assertEquals
(
q
.
wait
(),
'hi2'
)
timer
.
cancel
()
...
...
@@ -90,12 +90,12 @@ class TestQueue(TestCase):
results
=
set
()
def
collect_pending_results
():
for
i
,
e
in
enumerate
(
evts
):
timer
=
gevent
.
Timeout
(
0.001
,
gevent
.
TimeoutError
)
timer
=
gevent
.
Timeout
(
0.001
)
try
:
x
=
e
.
wait
()
results
.
add
(
x
)
timer
.
cancel
()
except
gevent
.
Timeout
Error
:
except
gevent
.
Timeout
:
pass
# no pending result at that event
return
len
(
results
)
q
.
send
(
sendings
[
0
])
...
...
greentest/test__proc.py
View file @
29c984ed
...
...
@@ -21,7 +21,7 @@
import
sys
import
greentest
from
gevent
import
sleep
,
with_timeout
,
Timeout
Error
,
getcurrent
from
gevent
import
sleep
,
with_timeout
,
Timeout
,
getcurrent
from
gevent
import
proc
,
coros
DELAY
=
0.01
...
...
@@ -35,10 +35,10 @@ class TestLink_Signal(greentest.TestCase):
s
=
proc
.
Source
()
q1
,
q2
,
q3
=
coros
.
Queue
(),
coros
.
Queue
(),
coros
.
Queue
()
s
.
link_value
(
q1
)
self
.
assertRaises
(
Timeout
Error
,
s
.
wait
,
0
)
self
.
assertRaises
(
Timeout
,
s
.
wait
,
0
)
assert
s
.
wait
(
0
,
None
)
is
None
assert
s
.
wait
(
0.001
,
None
)
is
None
self
.
assertRaises
(
Timeout
Error
,
s
.
wait
,
0.001
)
self
.
assertRaises
(
Timeout
,
s
.
wait
,
0.001
)
s
.
send
(
1
)
assert
not
q1
.
ready
()
assert
s
.
wait
()
==
1
...
...
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