summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSteven Hardy <shardy@redhat.com>2014-10-16 18:40:19 +0100
committerJakub Stasiak <jakub@stasiak.at>2014-11-15 13:35:06 +0000
commit34bcb6d15060140d7c15425d848dacdfc5b647bb (patch)
tree12f67f9fdaf401a42c0167d0c2eec67d626656a0 /tests
parent197000511e947224585a074161a8c6ac6b33306e (diff)
downloadeventlet-34bcb6d15060140d7c15425d848dacdfc5b647bb.tar.gz
Fix string concatenation errors
Some error paths concatenate the output of "type" with a string, which gives TypeError: cannot concatenate 'str' and 'type' objects, rather than describing the actual error. Closes #149 GH Closes #150 GH Conflicts: eventlet/hubs/twistedr.py
Diffstat (limited to 'tests')
-rw-r--r--tests/greenio_test.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/greenio_test.py b/tests/greenio_test.py
index e05a524..4b375ba 100644
--- a/tests/greenio_test.py
+++ b/tests/greenio_test.py
@@ -613,6 +613,38 @@ class TestGreenSocket(LimitedTestCase):
assert select.select([], [s1], [], 0) == ([], [s1], [])
+def test_get_fileno_of_a_socket_works():
+ class DummySocket(object):
+ def fileno(self):
+ return 123
+ assert select.get_fileno(DummySocket()) == 123
+
+
+def test_get_fileno_of_an_int_works():
+ assert select.get_fileno(123) == 123
+
+
+def test_get_fileno_of_wrong_type_fails():
+ try:
+ select.get_fileno('foo')
+ except TypeError as ex:
+ assert str(ex) == 'Expected int or long, got <type \'str\'>'
+ else:
+ assert False, 'Expected TypeError not raised'
+
+
+def test_get_fileno_of_a_socket_with_fileno_returning_wrong_type_fails():
+ class DummySocket(object):
+ def fileno(self):
+ return 'foo'
+ try:
+ select.get_fileno(DummySocket())
+ except TypeError as ex:
+ assert str(ex) == 'Expected int or long, got <type \'str\'>'
+ else:
+ assert False, 'Expected TypeError not raised'
+
+
class TestGreenPipe(LimitedTestCase):
@skip_on_windows
def setUp(self):