<s> """<STR_LIT>""" <EOL> import os <EOL> import struct <EOL> import sys <EOL> import unittest <EOL> from test . test_support import ( verbose , TESTFN , unlink , run_unittest , <EOL> import_module ) <EOL> fcntl = import_module ( '<STR_LIT>' ) <EOL> def get_lockdata ( ) : <EOL> if sys . platform . startswith ( '<STR_LIT>' ) : <EOL> start_len = "<STR_LIT>" <EOL> else : <EOL> try : <EOL> os . O_LARGEFILE <EOL> except AttributeError : <EOL> start_len = "<STR_LIT>" <EOL> else : <EOL> start_len = "<STR_LIT>" <EOL> if ( sys . platform . startswith ( ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> or sys . platform == '<STR_LIT>' ) : <EOL> if struct . calcsize ( '<STR_LIT:l>' ) == <NUM_LIT:8> : <EOL> off_t = '<STR_LIT:l>' <EOL> pid_t = '<STR_LIT:i>' <EOL> else : <EOL> off_t = '<STR_LIT>' <EOL> pid_t = '<STR_LIT:l>' <EOL> lockdata = struct . pack ( off_t + off_t + pid_t + '<STR_LIT>' , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <EOL> fcntl . F_WRLCK , <NUM_LIT:0> ) <EOL> elif sys . platform in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> lockdata = struct . pack ( '<STR_LIT>' , fcntl . F_WRLCK , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> elif sys . platform in [ '<STR_LIT>' ] : <EOL> lockdata = None <EOL> else : <EOL> lockdata = struct . pack ( '<STR_LIT>' + start_len + '<STR_LIT>' , fcntl . F_WRLCK , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> if lockdata : <EOL> if verbose : <EOL> print '<STR_LIT>' , repr ( lockdata ) <EOL> return lockdata <EOL> lockdata = get_lockdata ( ) <EOL> class TestFcntl ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . f = None <EOL> def tearDown ( self ) : <EOL> if self . f and not self . f . closed : <EOL> self . f . close ( ) <EOL> unlink ( TESTFN ) <EOL> def test_fcntl_fileno ( self ) : <EOL> self . f = open ( TESTFN , '<STR_LIT:w>' ) <EOL> rv = fcntl . fcntl ( self . f . fileno ( ) , fcntl . F_SETFL , os . O_NONBLOCK ) <EOL> if verbose : <EOL> print '<STR_LIT>' , rv <EOL> if sys . platform not in [ '<STR_LIT>' ] : <EOL> rv = fcntl . fcntl ( self . f . fileno ( ) , fcntl . F_SETLKW , lockdata ) <EOL> if verbose : <EOL> print '<STR_LIT>' , repr ( rv ) <EOL> self . f . close ( ) <EOL> def test_fcntl_file_descriptor ( self ) : <EOL> self . f = open ( TESTFN , '<STR_LIT:w>' ) <EOL> rv = fcntl . fcntl ( self . f , fcntl . F_SETFL , os . O_NONBLOCK ) <EOL> if sys . platform not in [ '<STR_LIT>' ] : <EOL> rv = fcntl . fcntl ( self . f , fcntl . F_SETLKW , lockdata ) <EOL> self . f . close ( ) <EOL> def test_fcntl_64_bit ( self ) : <EOL> try : <EOL> cmd = fcntl . F_NOTIFY <EOL> flags = fcntl . DN_MULTISHOT <EOL> except AttributeError : <EOL> self . skipTest ( "<STR_LIT>" ) <EOL> fd = os . open ( os . path . dirname ( os . path . abspath ( TESTFN ) ) , os . O_RDONLY ) <EOL> try : <EOL> fcntl . fcntl ( fd , cmd , flags ) <EOL> finally : <EOL> os . close ( fd ) <EOL> def test_main ( ) : <EOL> run_unittest ( TestFcntl ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> test_main ( ) </s>
