<s> import unittest <EOL> from test import test_support <EOL> import os <EOL> import subprocess <EOL> MacOS = test_support . import_module ( '<STR_LIT>' ) <EOL> TESTFN2 = test_support . TESTFN + '<STR_LIT:2>' <EOL> class TestMacOS ( unittest . TestCase ) : <EOL> def testGetCreatorAndType ( self ) : <EOL> if not os . path . exists ( '<STR_LIT>' ) : <EOL> return <EOL> try : <EOL> fp = open ( test_support . TESTFN , '<STR_LIT:w>' ) <EOL> fp . write ( '<STR_LIT:\n>' ) <EOL> fp . close ( ) <EOL> subprocess . call ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:-c>' , '<STR_LIT>' , <EOL> test_support . TESTFN ] ) <EOL> cr , tp = MacOS . GetCreatorAndType ( test_support . TESTFN ) <EOL> self . assertEqual ( tp , '<STR_LIT>' ) <EOL> self . assertEqual ( cr , '<STR_LIT>' ) <EOL> finally : <EOL> os . unlink ( test_support . TESTFN ) <EOL> def testSetCreatorAndType ( self ) : <EOL> if not os . path . exists ( '<STR_LIT>' ) : <EOL> return <EOL> try : <EOL> fp = open ( test_support . TESTFN , '<STR_LIT:w>' ) <EOL> fp . write ( '<STR_LIT:\n>' ) <EOL> fp . close ( ) <EOL> MacOS . SetCreatorAndType ( test_support . TESTFN , <EOL> '<STR_LIT>' , '<STR_LIT>' ) <EOL> cr , tp = MacOS . GetCreatorAndType ( test_support . TESTFN ) <EOL> self . assertEqual ( cr , '<STR_LIT>' ) <EOL> self . assertEqual ( tp , '<STR_LIT>' ) <EOL> data = subprocess . Popen ( [ "<STR_LIT>" , test_support . TESTFN ] , <EOL> stdout = subprocess . PIPE ) . communicate ( ) [ <NUM_LIT:0> ] <EOL> tp = None <EOL> cr = None <EOL> for ln in data . splitlines ( ) : <EOL> if ln . startswith ( '<STR_LIT>' ) : <EOL> tp = ln . split ( ) [ - <NUM_LIT:1> ] [ <NUM_LIT:1> : - <NUM_LIT:1> ] <EOL> if ln . startswith ( '<STR_LIT>' ) : <EOL> cr = ln . split ( ) [ - <NUM_LIT:1> ] [ <NUM_LIT:1> : - <NUM_LIT:1> ] <EOL> self . assertEqual ( cr , '<STR_LIT>' ) <EOL> self . assertEqual ( tp , '<STR_LIT>' ) <EOL> finally : <EOL> os . unlink ( test_support . TESTFN ) <EOL> def testOpenRF ( self ) : <EOL> try : <EOL> fp = open ( test_support . TESTFN , '<STR_LIT:w>' ) <EOL> fp . write ( '<STR_LIT>' ) <EOL> fp . close ( ) <EOL> rfp = MacOS . openrf ( test_support . TESTFN , '<STR_LIT>' ) <EOL> rfp . write ( '<STR_LIT>' ) <EOL> rfp . close ( ) <EOL> fp = open ( test_support . TESTFN , '<STR_LIT:r>' ) <EOL> data = fp . read ( ) <EOL> fp . close ( ) <EOL> self . assertEqual ( data , '<STR_LIT>' ) <EOL> rfp = MacOS . openrf ( test_support . TESTFN , '<STR_LIT>' ) <EOL> data = rfp . read ( <NUM_LIT:100> ) <EOL> data2 = rfp . read ( <NUM_LIT:100> ) <EOL> rfp . close ( ) <EOL> self . assertEqual ( data , '<STR_LIT>' ) <EOL> self . assertEqual ( data2 , '<STR_LIT>' ) <EOL> finally : <EOL> os . unlink ( test_support . TESTFN ) <EOL> def test_main ( ) : <EOL> test_support . run_unittest ( TestMacOS ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> test_main ( ) </s>
