summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorRonald Oussoren <ronaldoussoren@mac.com>2009-01-02 14:10:20 (GMT)
committerRonald Oussoren <ronaldoussoren@mac.com>2009-01-02 14:10:20 (GMT)
commit0238497e931f439ff4e1ebe268f31ce23c15407f (patch)
treec62c49a7d4905def8e111b8f65d8f1ea67ce9758 /Lib
parent8c95484cff12e96356f67d31e3fa5e5aa7dbd5ca (diff)
downloadcpython-0238497e931f439ff4e1ebe268f31ce23c15407f.zip
cpython-0238497e931f439ff4e1ebe268f31ce23c15407f.tar.gz
cpython-0238497e931f439ff4e1ebe268f31ce23c15407f.tar.bz2
Fix for issue1594
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_macos.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/Lib/test/test_macos.py b/Lib/test/test_macos.py
index e65b174..a9ff0b2 100644
--- a/Lib/test/test_macos.py
+++ b/Lib/test/test_macos.py
@@ -3,11 +3,66 @@ import MacOS
import Carbon.File
from test import test_support
import os
+import subprocess
TESTFN2 = test_support.TESTFN + '2'
class TestMacOS(unittest.TestCase):
+ def testGetCreatorAndType(self):
+ if not os.path.exists('/Developer/Tools/SetFile'):
+ return
+
+ try:
+ fp = open(test_support.TESTFN, 'w')
+ fp.write('\n')
+ fp.close()
+
+ subprocess.call(
+ ['/Developer/Tools/SetFile', '-t', 'ABCD', '-c', 'EFGH',
+ test_support.TESTFN])
+
+ cr, tp = MacOS.GetCreatorAndType(test_support.TESTFN)
+ self.assertEquals(tp, 'ABCD')
+ self.assertEquals(cr, 'EFGH')
+
+ finally:
+ os.unlink(test_support.TESTFN)
+
+ def testSetCreatorAndType(self):
+ if not os.path.exists('/Developer/Tools/GetFileInfo'):
+ return
+
+ try:
+ fp = open(test_support.TESTFN, 'w')
+ fp.write('\n')
+ fp.close()
+
+ MacOS.SetCreatorAndType(test_support.TESTFN,
+ 'ABCD', 'EFGH')
+
+ cr, tp = MacOS.GetCreatorAndType(test_support.TESTFN)
+ self.assertEquals(cr, 'ABCD')
+ self.assertEquals(tp, 'EFGH')
+
+ data = subprocess.Popen(["/Developer/Tools/GetFileInfo", test_support.TESTFN],
+ stdout=subprocess.PIPE).communicate()[0]
+
+ tp = None
+ cr = None
+ for ln in data.splitlines():
+ if ln.startswith('type:'):
+ tp = ln.split()[-1][1:-1]
+ if ln.startswith('creator:'):
+ cr = ln.split()[-1][1:-1]
+
+ self.assertEquals(cr, 'ABCD')
+ self.assertEquals(tp, 'EFGH')
+
+ finally:
+ os.unlink(test_support.TESTFN)
+
+
def testOpenRF(self):
try:
fp = open(test_support.TESTFN, 'w')