1
# Copyright (C) 2003 Python Software Foundation
9
from test import test_support
11
TESTFN2 = test_support.TESTFN + '2'
13
class TestMacostools(unittest.TestCase):
16
fp = open(test_support.TESTFN, 'w')
17
fp.write('hello world\n')
19
rfp = MacOS.openrf(test_support.TESTFN, '*wb')
20
rfp.write('goodbye world\n')
25
os.unlink(test_support.TESTFN)
33
def compareData(self):
34
fp = open(test_support.TESTFN, 'r')
37
fp = open(TESTFN2, 'r')
41
return 'Data forks differ'
42
rfp = MacOS.openrf(test_support.TESTFN, '*rb')
43
data1 = rfp.read(1000)
45
rfp = MacOS.openrf(TESTFN2, '*rb')
46
data2 = rfp.read(1000)
49
return 'Resource forks differ'
52
def test_touched(self):
53
# This really only tests that nothing unforeseen happens.
54
macostools.touched(test_support.TESTFN)
61
macostools.copy(test_support.TESTFN, TESTFN2)
62
self.assertEqual(self.compareData(), '')
64
def test_mkalias(self):
69
macostools.mkalias(test_support.TESTFN, TESTFN2)
70
fss, _, _ = Carbon.File.ResolveAliasFile(TESTFN2, 0)
71
self.assertEqual(fss.as_pathname(), os.path.realpath(test_support.TESTFN))
73
def test_mkalias_relative(self):
74
if not os.path.exists(sys.prefix):
80
macostools.mkalias(test_support.TESTFN, TESTFN2, sys.prefix)
81
fss, _, _ = Carbon.File.ResolveAliasFile(TESTFN2, 0)
82
self.assertEqual(fss.as_pathname(), os.path.realpath(test_support.TESTFN))
86
test_support.run_unittest(TestMacostools)
89
if __name__ == '__main__':