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
21f96760
Commit
21f96760
authored
Sep 24, 2012
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use greentest instead of unittest
in 5 more tests; this ensures more checks, esp. in debug mode
parent
e23fb41a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
27 deletions
+34
-27
greentest/test__core_watcher.py
greentest/test__core_watcher.py
+6
-3
greentest/test__local.py
greentest/test__local.py
+3
-3
greentest/test__server_pywsgi.py
greentest/test__server_pywsgi.py
+2
-2
greentest/test__socket_ssl.py
greentest/test__socket_ssl.py
+3
-3
greentest/test__socket_timeout.py
greentest/test__socket_timeout.py
+20
-16
No files found.
greentest/test__core_watcher.py
View file @
21f96760
import
unit
test
import
green
test
from
gevent
import
core
from
gevent
import
core
class
Test
(
unit
test
.
TestCase
):
class
Test
(
green
test
.
TestCase
):
def
test_types
(
self
):
def
test_types
(
self
):
loop
=
core
.
loop
()
loop
=
core
.
loop
()
...
@@ -43,8 +43,11 @@ class Test(unittest.TestCase):
...
@@ -43,8 +43,11 @@ class Test(unittest.TestCase):
self
.
assertEqual
(
io
.
args
,
(
1
,
2
,
3
))
self
.
assertEqual
(
io
.
args
,
(
1
,
2
,
3
))
# None also works, means empty tuple
# None also works, means empty tuple
io
.
args
=
None
io
.
args
=
None
start
=
core
.
time
()
loop
.
run
()
loop
.
run
()
took
=
core
.
time
()
-
start
self
.
assertEqual
(
lst
,
[()])
self
.
assertEqual
(
lst
,
[()])
assert
took
<
1
,
took
io
.
start
(
reset
,
io
,
lst
)
io
.
start
(
reset
,
io
,
lst
)
del
io
del
io
...
@@ -59,4 +62,4 @@ def reset(watcher, lst):
...
@@ -59,4 +62,4 @@ def reset(watcher, lst):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unit
test
.
main
()
green
test
.
main
()
greentest/test__local.py
View file @
21f96760
import
unit
test
import
green
test
from
copy
import
copy
from
copy
import
copy
# Comment the line below to see that the standard thread.local is working correct
# Comment the line below to see that the standard thread.local is working correct
from
gevent
import
monkey
;
monkey
.
patch_all
()
from
gevent
import
monkey
;
monkey
.
patch_all
()
...
@@ -22,7 +22,7 @@ class Obj(object):
...
@@ -22,7 +22,7 @@ class Obj(object):
pass
pass
class
GeventLocalTestCase
(
unit
test
.
TestCase
):
class
GeventLocalTestCase
(
green
test
.
TestCase
):
def
test_copy
(
self
):
def
test_copy
(
self
):
a
=
A
(
Obj
())
a
=
A
(
Obj
())
...
@@ -59,4 +59,4 @@ class GeventLocalTestCase(unittest.TestCase):
...
@@ -59,4 +59,4 @@ class GeventLocalTestCase(unittest.TestCase):
self
.
assertNotEqual
(
a
.
path
,
b
.
path
,
'The values in the two objects must be different'
)
self
.
assertNotEqual
(
a
.
path
,
b
.
path
,
'The values in the two objects must be different'
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unit
test
.
main
()
green
test
.
main
()
greentest/test__server_pywsgi.py
View file @
21f96760
import
unit
test
import
green
test
import
gevent
import
gevent
from
gevent
import
pywsgi
from
gevent
import
pywsgi
import
test__server
import
test__server
...
@@ -81,4 +81,4 @@ test__server.Settings = Settings
...
@@ -81,4 +81,4 @@ test__server.Settings = Settings
del
TestNoneSpawn
del
TestNoneSpawn
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unit
test
.
main
()
green
test
.
main
()
greentest/test__socket_ssl.py
View file @
21f96760
#!/usr/bin/python
#!/usr/bin/python
from
gevent
import
monkey
;
monkey
.
patch_all
()
from
gevent
import
monkey
;
monkey
.
patch_all
()
import
sys
import
sys
import
unit
test
import
green
test
try
:
try
:
import
httplib
import
httplib
except
ImportError
:
except
ImportError
:
...
@@ -12,7 +12,7 @@ if not hasattr(socket, 'ssl'):
...
@@ -12,7 +12,7 @@ if not hasattr(socket, 'ssl'):
sys
.
exit
(
0
)
sys
.
exit
(
0
)
class
AmazonHTTPSTests
(
unit
test
.
TestCase
):
class
AmazonHTTPSTests
(
green
test
.
TestCase
):
def
test_amazon_response
(
self
):
def
test_amazon_response
(
self
):
conn
=
httplib
.
HTTPSConnection
(
'sdb.amazonaws.com'
)
conn
=
httplib
.
HTTPSConnection
(
'sdb.amazonaws.com'
)
...
@@ -29,4 +29,4 @@ class AmazonHTTPSTests(unittest.TestCase):
...
@@ -29,4 +29,4 @@ class AmazonHTTPSTests(unittest.TestCase):
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
unit
test
.
main
()
green
test
.
main
()
greentest/test__socket_timeout.py
View file @
21f96760
import
sys
import
sys
import
gevent
import
gevent
from
gevent
import
socket
from
gevent
import
socket
import
unit
test
import
green
test
class
Test
(
unit
test
.
TestCase
):
class
Test
(
green
test
.
TestCase
):
def
s
etUp
(
self
):
def
s
tart
(
self
):
self
.
server
=
socket
.
socket
()
self
.
server
=
socket
.
socket
()
self
.
server
.
bind
((
'127.0.0.1'
,
0
))
self
.
server
.
bind
((
'127.0.0.1'
,
0
))
self
.
server
.
listen
(
1
)
self
.
server
.
listen
(
1
)
self
.
server_port
=
self
.
server
.
getsockname
()[
1
]
self
.
server_port
=
self
.
server
.
getsockname
()[
1
]
self
.
acceptor
=
gevent
.
spawn
(
self
.
server
.
accept
)
self
.
acceptor
=
gevent
.
spawn
(
self
.
server
.
accept
)
def
tearDown
(
self
):
def
stop
(
self
):
self
.
server
.
close
()
self
.
server
.
close
()
self
.
acceptor
.
kill
()
self
.
acceptor
.
kill
()
del
self
.
acceptor
del
self
.
acceptor
del
self
.
server
del
self
.
server
def
test
(
self
):
def
test
(
self
):
sock
=
socket
.
socket
()
self
.
start
()
sock
.
connect
((
'127.0.0.1'
,
self
.
server_port
))
try
:
try
:
sock
.
settimeout
(
0.1
)
sock
=
socket
.
socket
()
sock
.
connect
((
'127.0.0.1'
,
self
.
server_port
))
try
:
try
:
result
=
sock
.
recv
(
1024
)
sock
.
settimeout
(
0.1
)
raise
AssertionError
(
'Expected timeout to be raised, instead recv() returned %r'
%
(
result
,
))
try
:
except
socket
.
error
:
result
=
sock
.
recv
(
1024
)
ex
=
sys
.
exc_info
()[
1
]
raise
AssertionError
(
'Expected timeout to be raised, instead recv() returned %r'
%
(
result
,
))
self
.
assertEqual
(
ex
.
args
,
(
'timed out'
,))
except
socket
.
error
:
self
.
assertEqual
(
str
(
ex
),
'timed out'
)
ex
=
sys
.
exc_info
()[
1
]
self
.
assertEqual
(
ex
[
0
],
'timed out'
)
self
.
assertEqual
(
ex
.
args
,
(
'timed out'
,))
self
.
assertEqual
(
str
(
ex
),
'timed out'
)
self
.
assertEqual
(
ex
[
0
],
'timed out'
)
finally
:
sock
.
close
()
finally
:
finally
:
s
ock
.
close
()
s
elf
.
stop
()
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unit
test
.
main
()
green
test
.
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