@@ -3659,6 +3659,33 @@ def test_set_inheritable_cloexec(self):
36593659 self .assertEqual (fcntl .fcntl (fd , fcntl .F_GETFD ) & fcntl .FD_CLOEXEC ,
36603660 0 )
36613661
3662+ @unittest .skipUnless (hasattr (os , 'O_PATH' ), "need os.O_PATH" )
3663+ def test_get_set_inheritable_o_path (self ):
3664+ fd = os .open (__file__ , os .O_PATH )
3665+ self .addCleanup (os .close , fd )
3666+ self .assertEqual (os .get_inheritable (fd ), False )
3667+
3668+ os .set_inheritable (fd , True )
3669+ self .assertEqual (os .get_inheritable (fd ), True )
3670+
3671+ os .set_inheritable (fd , False )
3672+ self .assertEqual (os .get_inheritable (fd ), False )
3673+
3674+ def test_get_set_inheritable_badf (self ):
3675+ fd = support .make_bad_fd ()
3676+
3677+ with self .assertRaises (OSError ) as ctx :
3678+ os .get_inheritable (fd )
3679+ self .assertEqual (ctx .exception .errno , errno .EBADF )
3680+
3681+ with self .assertRaises (OSError ) as ctx :
3682+ os .set_inheritable (fd , True )
3683+ self .assertEqual (ctx .exception .errno , errno .EBADF )
3684+
3685+ with self .assertRaises (OSError ) as ctx :
3686+ os .set_inheritable (fd , False )
3687+ self .assertEqual (ctx .exception .errno , errno .EBADF )
3688+
36623689 def test_open (self ):
36633690 fd = os .open (__file__ , os .O_RDONLY )
36643691 self .addCleanup (os .close , fd )
0 commit comments