summaryrefslogtreecommitdiff
path: root/tests/api_test.py
diff options
context:
space:
mode:
authorSergey Shepelev <temotor@gmail.com>2014-04-24 17:51:27 +0400
committerSergey Shepelev <temotor@gmail.com>2014-04-24 18:11:37 +0400
commitcbd404d56e231ea5419f07795a12d7082dd70ec4 (patch)
tree7ad24a0f80e064b94108bb38b8c4a8a3eebafb44 /tests/api_test.py
parentc467ded4a6e777518cd7a3888149510e3b31d334 (diff)
downloadeventlet-cbd404d56e231ea5419f07795a12d7082dd70ec4.tar.gz
python3 compatibility
- __next__ for iterator interface - six.next() to get next item - list(dict.keys()) - popen2.popen4 -> subprocess - s2b -> b"..." literals - deprecated assertEquals -> assertEqual - hub_test test_fork using run_python - 1L -> 1 long literal - many PEP-8 fixes
Diffstat (limited to 'tests/api_test.py')
-rw-r--r--tests/api_test.py30
1 files changed, 17 insertions, 13 deletions
diff --git a/tests/api_test.py b/tests/api_test.py
index 3ed98a8..2ee0886 100644
--- a/tests/api_test.py
+++ b/tests/api_test.py
@@ -4,12 +4,12 @@ from unittest import TestCase, main
import warnings
import eventlet
+from eventlet import greenio, util, hubs, greenthread, spawn
+from tests import skip_if_no_ssl
+
warnings.simplefilter('ignore', DeprecationWarning)
from eventlet import api
warnings.simplefilter('default', DeprecationWarning)
-from eventlet import greenio, util, hubs, greenthread, spawn
-
-from tests import skip_if_no_ssl
def check_hub():
@@ -57,7 +57,7 @@ class TestApi(TestCase):
client.close()
assert fd.readline() == b'hello\n'
- assert fd.read() == ''
+ assert fd.read() == b''
fd.close()
check_hub()
@@ -85,7 +85,7 @@ class TestApi(TestCase):
assert fd.readline() == b'hello\r\n'
try:
- self.assertEquals('', fd.read(10))
+ self.assertEqual(b'', fd.read(10))
except greenio.SSL.ZeroReturnError:
# if it's a GreenSSL object it'll do this
pass
@@ -147,9 +147,7 @@ class TestApi(TestCase):
def test_named(self):
named_foo = api.named('tests.api_test.Foo')
- self.assertEquals(
- named_foo.__name__,
- "Foo")
+ self.assertEqual(named_foo.__name__, "Foo")
def test_naming_missing_class(self):
self.assertRaises(
@@ -171,19 +169,25 @@ class TestApi(TestCase):
# thus after the function's done, the control will go to the parent
api.sleep(0)
state.append('finished')
+
g = api.spawn(test)
- api.sleep(DELAY/2)
- self.assertEquals(state, ['start'])
+ api.sleep(DELAY / 2)
+ self.assertEqual(state, ['start'])
api.kill(g)
# will not get there, unless switching is explicitly scheduled by kill
- self.assertEquals(state, ['start', 'except'])
+ self.assertEqual(state, ['start', 'except'])
api.sleep(DELAY)
- self.assertEquals(state, ['start', 'except', 'finished'])
+ self.assertEqual(state, ['start', 'except', 'finished'])
def test_nested_with_timeout(self):
def func():
return api.with_timeout(0.2, api.sleep, 2, timeout_value=1)
- self.assertRaises(api.TimeoutError, api.with_timeout, 0.1, func)
+
+ try:
+ api.with_timeout(0.1, func)
+ self.fail(u'Expected api.TimeoutError')
+ except api.TimeoutError:
+ pass
class Foo(object):