5
5
import unittest
6
6
import errno
7
7
from errno import EEXIST
8
- import sys
9
8
10
9
11
10
class SubOSError (OSError ):
@@ -41,10 +40,10 @@ def test_builtin_errors(self):
41
40
self .assertIs (EnvironmentError , OSError )
42
41
43
42
def test_socket_errors (self ):
44
- self .assertIs (socket .error , IOError )
43
+ self .assertIs (socket .error , OSError )
45
44
self .assertIs (socket .gaierror .__base__ , OSError )
46
45
self .assertIs (socket .herror .__base__ , OSError )
47
- self .assertIs (socket .timeout . __base__ , OSError )
46
+ self .assertIs (socket .timeout , TimeoutError )
48
47
49
48
def test_select_error (self ):
50
49
self .assertIs (select .error , OSError )
@@ -64,7 +63,7 @@ def test_select_error(self):
64
63
+-- InterruptedError EINTR
65
64
+-- IsADirectoryError EISDIR
66
65
+-- NotADirectoryError ENOTDIR
67
- +-- PermissionError EACCES, EPERM
66
+ +-- PermissionError EACCES, EPERM, ENOTCAPABLE
68
67
+-- ProcessLookupError ESRCH
69
68
+-- TimeoutError ETIMEDOUT
70
69
"""
@@ -76,6 +75,8 @@ def _make_map(s):
76
75
continue
77
76
excname , _ , errnames = line .partition (' ' )
78
77
for errname in filter (None , errnames .strip ().split (', ' )):
78
+ if errname == "ENOTCAPABLE" and not hasattr (errno , errname ):
79
+ continue
79
80
_map [getattr (errno , errname )] = getattr (builtins , excname )
80
81
return _map
81
82
_map = _make_map (_pep_map )
@@ -93,7 +94,7 @@ def test_errno_mapping(self):
93
94
othercodes = set (errno .errorcode ) - set (self ._map )
94
95
for errcode in othercodes :
95
96
e = OSError (errcode , "Some message" )
96
- self .assertIs (type (e ), OSError )
97
+ self .assertIs (type (e ), OSError , repr ( e ) )
97
98
98
99
def test_try_except (self ):
99
100
filename = "some_hopefully_non_existing_file"
@@ -128,7 +129,6 @@ def test_windows_error(self):
128
129
self .assertNotIn ('winerror' , dir (OSError ))
129
130
130
131
@unittest .skip ("TODO: RUSTPYTHON" )
131
- @unittest .skipIf (sys .platform == 'win32' , 'winerror not filled yet' )
132
132
def test_posix_error (self ):
133
133
e = OSError (EEXIST , "File already exists" , "foo.txt" )
134
134
self .assertEqual (e .errno , EEXIST )
0 commit comments