55import unittest
66import errno
77from errno import EEXIST
8- import sys
98
109
1110class SubOSError (OSError ):
@@ -41,10 +40,10 @@ def test_builtin_errors(self):
4140 self .assertIs (EnvironmentError , OSError )
4241
4342 def test_socket_errors (self ):
44- self .assertIs (socket .error , IOError )
43+ self .assertIs (socket .error , OSError )
4544 self .assertIs (socket .gaierror .__base__ , OSError )
4645 self .assertIs (socket .herror .__base__ , OSError )
47- self .assertIs (socket .timeout . __base__ , OSError )
46+ self .assertIs (socket .timeout , TimeoutError )
4847
4948 def test_select_error (self ):
5049 self .assertIs (select .error , OSError )
@@ -64,7 +63,7 @@ def test_select_error(self):
6463 +-- InterruptedError EINTR
6564 +-- IsADirectoryError EISDIR
6665 +-- NotADirectoryError ENOTDIR
67- +-- PermissionError EACCES, EPERM
66+ +-- PermissionError EACCES, EPERM, ENOTCAPABLE
6867 +-- ProcessLookupError ESRCH
6968 +-- TimeoutError ETIMEDOUT
7069 """
@@ -76,6 +75,8 @@ def _make_map(s):
7675 continue
7776 excname , _ , errnames = line .partition (' ' )
7877 for errname in filter (None , errnames .strip ().split (', ' )):
78+ if errname == "ENOTCAPABLE" and not hasattr (errno , errname ):
79+ continue
7980 _map [getattr (errno , errname )] = getattr (builtins , excname )
8081 return _map
8182 _map = _make_map (_pep_map )
@@ -93,7 +94,7 @@ def test_errno_mapping(self):
9394 othercodes = set (errno .errorcode ) - set (self ._map )
9495 for errcode in othercodes :
9596 e = OSError (errcode , "Some message" )
96- self .assertIs (type (e ), OSError )
97+ self .assertIs (type (e ), OSError , repr ( e ) )
9798
9899 def test_try_except (self ):
99100 filename = "some_hopefully_non_existing_file"
@@ -128,7 +129,6 @@ def test_windows_error(self):
128129 self .assertNotIn ('winerror' , dir (OSError ))
129130
130131 @unittest .skip ("TODO: RUSTPYTHON" )
131- @unittest .skipIf (sys .platform == 'win32' , 'winerror not filled yet' )
132132 def test_posix_error (self ):
133133 e = OSError (EEXIST , "File already exists" , "foo.txt" )
134134 self .assertEqual (e .errno , EEXIST )
0 commit comments