]> granicus.if.org Git - python/commitdiff
Issue #12367: Add a test on error attribute of select.error
authorVictor Stinner <victor.stinner@haypocalc.com>
Wed, 12 Oct 2011 19:01:46 +0000 (21:01 +0200)
committerVictor Stinner <victor.stinner@haypocalc.com>
Wed, 12 Oct 2011 19:01:46 +0000 (21:01 +0200)
Thanks to the PEP 3151, select.error (which is just an alias to OSError) has
now an error attribute.

Lib/test/test_select.py

index 4a13adebfda4d63c056c31c14c4751ca17c9f6bd..c503440bd0771d30c7a0f1afa9ae551049367ea4 100644 (file)
@@ -1,8 +1,9 @@
-from test import support
-import unittest
-import select
+import errno
 import os
+import select
 import sys
+import unittest
+from test import support
 
 @unittest.skipIf(sys.platform[:3] in ('win', 'os2', 'riscos'),
                  "can't easily test on this system")
@@ -22,6 +23,17 @@ class SelectTestCase(unittest.TestCase):
         self.assertRaises(TypeError, select.select, [], [], [], "not a number")
         self.assertRaises(ValueError, select.select, [], [], [], -1)
 
+    def test_errno(self):
+        with open(__file__, 'rb') as fp:
+            fd = fp.fileno()
+            fp.close()
+            try:
+                select.select([fd], [], [])
+            except select.error as err:
+                self.assertEqual(err.errno, errno.EBADF)
+            else:
+                self.fail("exception not raised")
+
     def test_returned_list_identity(self):
         # See issue #8329
         r, w, x = select.select([], [], [], 1)