summaryrefslogtreecommitdiff
path: root/tests/test_py33_exceptions.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_py33_exceptions.py')
-rw-r--r--tests/test_py33_exceptions.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/test_py33_exceptions.py b/tests/test_py33_exceptions.py
new file mode 100644
index 0000000..42fb4e2
--- /dev/null
+++ b/tests/test_py33_exceptions.py
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+"""
+Tests for py33_exceptions.
+
+"""
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+
+
+import unittest
+from trollius import py33_exceptions
+
+class TestWrapErrors(unittest.TestCase):
+
+ def test_ebadf_wrapped_to_OSError(self):
+ # https://github.com/jamadden/trollius/issues/17
+ import socket
+ import os
+ import errno
+ s = socket.socket()
+ os.close(s.fileno())
+
+ with self.assertRaises(socket.error) as exc:
+ s.send(b'abc')
+
+ self.assertEqual(exc.exception.errno, errno.EBADF)
+
+ with self.assertRaises(OSError) as exc:
+ py33_exceptions.wrap_error(s.send, b'abc')
+
+ self.assertEqual(exc.exception.errno, errno.EBADF)
+
+if __name__ == '__main__':
+ unittest.main()