Changeset 391 for python/trunk/Lib/test/test_macos.py
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Lib/test/test_macos.py
r2 r391 1 1 import unittest 2 import MacOS3 import Carbon.File4 2 from test import test_support 5 3 import os 4 import subprocess 5 6 MacOS = test_support.import_module('MacOS') 6 7 7 8 TESTFN2 = test_support.TESTFN + '2' 8 9 9 10 class TestMacOS(unittest.TestCase): 11 12 def testGetCreatorAndType(self): 13 if not os.path.exists('/Developer/Tools/SetFile'): 14 return 15 16 try: 17 fp = open(test_support.TESTFN, 'w') 18 fp.write('\n') 19 fp.close() 20 21 subprocess.call( 22 ['/Developer/Tools/SetFile', '-t', 'ABCD', '-c', 'EFGH', 23 test_support.TESTFN]) 24 25 cr, tp = MacOS.GetCreatorAndType(test_support.TESTFN) 26 self.assertEqual(tp, 'ABCD') 27 self.assertEqual(cr, 'EFGH') 28 29 finally: 30 os.unlink(test_support.TESTFN) 31 32 def testSetCreatorAndType(self): 33 if not os.path.exists('/Developer/Tools/GetFileInfo'): 34 return 35 36 try: 37 fp = open(test_support.TESTFN, 'w') 38 fp.write('\n') 39 fp.close() 40 41 MacOS.SetCreatorAndType(test_support.TESTFN, 42 'ABCD', 'EFGH') 43 44 cr, tp = MacOS.GetCreatorAndType(test_support.TESTFN) 45 self.assertEqual(cr, 'ABCD') 46 self.assertEqual(tp, 'EFGH') 47 48 data = subprocess.Popen(["/Developer/Tools/GetFileInfo", test_support.TESTFN], 49 stdout=subprocess.PIPE).communicate()[0] 50 51 tp = None 52 cr = None 53 for ln in data.splitlines(): 54 if ln.startswith('type:'): 55 tp = ln.split()[-1][1:-1] 56 if ln.startswith('creator:'): 57 cr = ln.split()[-1][1:-1] 58 59 self.assertEqual(cr, 'ABCD') 60 self.assertEqual(tp, 'EFGH') 61 62 finally: 63 os.unlink(test_support.TESTFN) 64 10 65 11 66 def testOpenRF(self): … … 23 78 data = fp.read() 24 79 fp.close() 25 self.assertEqual s(data, 'hello world\n')80 self.assertEqual(data, 'hello world\n') 26 81 27 82 rfp = MacOS.openrf(test_support.TESTFN, '*rb') … … 29 84 data2 = rfp.read(100) 30 85 rfp.close() 31 self.assertEqual s(data, 'goodbye world\n')32 self.assertEqual s(data2, '')86 self.assertEqual(data, 'goodbye world\n') 87 self.assertEqual(data2, '') 33 88 34 89
Note:
See TracChangeset
for help on using the changeset viewer.