Commit 21f96760 authored by Denis Bilenko's avatar Denis Bilenko

use greentest instead of unittest

in 5 more tests; this ensures more checks, esp. in debug mode
parent e23fb41a
import unittest
import greentest
from gevent import core
class Test(unittest.TestCase):
class Test(greentest.TestCase):
def test_types(self):
loop = core.loop()
......@@ -43,8 +43,11 @@ class Test(unittest.TestCase):
self.assertEqual(io.args, (1, 2, 3))
# None also works, means empty tuple
io.args = None
start = core.time()
loop.run()
took = core.time() - start
self.assertEqual(lst, [()])
assert took < 1, took
io.start(reset, io, lst)
del io
......@@ -59,4 +62,4 @@ def reset(watcher, lst):
if __name__ == '__main__':
unittest.main()
greentest.main()
import unittest
import greentest
from copy import copy
# Comment the line below to see that the standard thread.local is working correct
from gevent import monkey; monkey.patch_all()
......@@ -22,7 +22,7 @@ class Obj(object):
pass
class GeventLocalTestCase(unittest.TestCase):
class GeventLocalTestCase(greentest.TestCase):
def test_copy(self):
a = A(Obj())
......@@ -59,4 +59,4 @@ class GeventLocalTestCase(unittest.TestCase):
self.assertNotEqual(a.path, b.path, 'The values in the two objects must be different')
if __name__ == '__main__':
unittest.main()
greentest.main()
import unittest
import greentest
import gevent
from gevent import pywsgi
import test__server
......@@ -81,4 +81,4 @@ test__server.Settings = Settings
del TestNoneSpawn
if __name__ == '__main__':
unittest.main()
greentest.main()
#!/usr/bin/python
from gevent import monkey; monkey.patch_all()
import sys
import unittest
import greentest
try:
import httplib
except ImportError:
......@@ -12,7 +12,7 @@ if not hasattr(socket, 'ssl'):
sys.exit(0)
class AmazonHTTPSTests(unittest.TestCase):
class AmazonHTTPSTests(greentest.TestCase):
def test_amazon_response(self):
conn = httplib.HTTPSConnection('sdb.amazonaws.com')
......@@ -29,4 +29,4 @@ class AmazonHTTPSTests(unittest.TestCase):
if __name__ == "__main__":
unittest.main()
greentest.main()
import sys
import gevent
from gevent import socket
import unittest
import greentest
class Test(unittest.TestCase):
class Test(greentest.TestCase):
def setUp(self):
def start(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):
def stop(self):
self.server.close()
self.acceptor.kill()
del self.acceptor
del self.server
def test(self):
self.start()
try:
sock = socket.socket()
sock.connect(('127.0.0.1', self.server_port))
try:
......@@ -34,7 +36,9 @@ class Test(unittest.TestCase):
self.assertEqual(ex[0], 'timed out')
finally:
sock.close()
finally:
self.stop()
if __name__ == '__main__':
unittest.main()
greentest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment