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
7f0cda6e
Commit
7f0cda6e
authored
Aug 29, 2012
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test__examples.py: add minimal time check
parent
d59b9103
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
12 deletions
+21
-12
greentest/test__examples.py
greentest/test__examples.py
+21
-12
No files found.
greentest/test__examples.py
View file @
7f0cda6e
...
...
@@ -20,6 +20,7 @@ from gevent.server import DatagramServer, StreamServer
examples_directory
=
normpath
(
join
(
dirname
(
abspath
(
__file__
)),
'..'
,
'examples'
))
examples
=
[
basename
(
x
)
for
x
in
glob
.
glob
(
examples_directory
+
'/*.py'
)]
simple_examples
=
[]
default_time_range
=
(
0.0
,
10.0
)
for
example
in
examples
:
...
...
@@ -27,6 +28,18 @@ for example in examples:
simple_examples
.
append
(
example
)
class
TestCase
(
unittest
.
TestCase
):
def
run_script
(
self
,
*
args
,
**
kwargs
):
cmd
=
[
sys
.
executable
,
join
(
examples_directory
,
self
.
path
)]
+
list
(
args
)
start
=
time
()
subprocess
.
check_call
(
cmd
,
**
kwargs
)
took
=
time
()
-
start
min_time
,
max_time
=
getattr
(
self
,
'time_range'
,
default_time_range
)
assert
took
>=
min_time
,
'%s exited too quickly %s %s'
%
(
self
.
path
,
took
,
min_time
)
assert
took
<=
max_time
,
'%s takes way too long %s %s'
%
(
self
.
path
,
took
,
max_time
)
def
make_test
(
path
):
if
sys
.
platform
==
'win32'
and
os
.
path
.
basename
(
path
)
in
(
'geventsendfile.py'
,
'processes.py'
):
...
...
@@ -36,25 +49,17 @@ def make_test(path):
if
' '
in
path
:
path
=
'"%s"'
%
path
class
Test
(
unittest
.
TestCase
):
class
Test
(
TestCase
):
def
test
(
self
):
run_script
(
self
.
path
)
self
.
run_script
(
)
Test
.
__name__
=
'Test_'
+
basename
(
path
).
split
(
'.'
)[
0
]
assert
Test
.
__name__
not
in
globals
(),
Test
.
__name__
Test
.
path
=
path
return
Test
def
run_script
(
path
,
*
args
):
cmd
=
[
sys
.
executable
,
join
(
examples_directory
,
path
)]
+
list
(
args
)
popen
=
subprocess
.
Popen
(
cmd
)
if
popen
.
wait
()
!=
0
:
raise
AssertionError
(
'%r failed with code %s'
%
(
cmd
,
popen
.
wait
()))
def
kill
(
popen
):
try
:
popen
.
kill
()
...
...
@@ -221,7 +226,7 @@ class Test_echoserver(BaseTestServer):
gevent
.
joinall
([
client1
,
client2
],
raise_error
=
True
)
class
Test_udp_client
(
unittest
.
TestCase
):
class
Test_udp_client
(
TestCase
):
path
=
'udp_client.py'
...
...
@@ -233,7 +238,7 @@ class Test_udp_client(unittest.TestCase):
server
=
DatagramServer
(
'127.0.0.1:9000'
,
handle
)
server
.
start
()
try
:
run_script
(
self
.
path
,
'Test_udp_client'
)
self
.
run_script
(
'Test_udp_client'
)
finally
:
server
.
close
()
self
.
assertEqual
(
log
,
[
'Test_udp_client'
])
...
...
@@ -306,6 +311,10 @@ for example in simple_examples:
del
test
Test_psycopg2_pool
.
time_range
=
(
2.0
,
2.5
)
Test_threadpool
.
time_range
=
(
2.0
,
3.0
)
class
TestAllTested
(
unittest
.
TestCase
):
def
test
(
self
):
...
...
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