1 # Copyright (C) 2003 Python Software Foundation
5 from test
import test_support
8 MacOS
= test_support
.import_module('MacOS')
9 # The following should exist if MacOS does.
14 dataforkdata
= 'hello\r\0world\n'
15 resourceforkdata
= 'goodbye\ncruel\0world\r'
17 applesingledata
= struct
.pack(">ll16sh", AS_MAGIC
, AS_VERSION
, "foo", 2) + \
18 struct
.pack(">llllll", 1, 50, len(dataforkdata
),
19 2, 50+len(dataforkdata
), len(resourceforkdata
)) + \
22 TESTFN2
= test_support
.TESTFN
+ '2'
24 class TestApplesingle(unittest
.TestCase
):
27 fp
= open(test_support
.TESTFN
, 'w')
28 fp
.write(applesingledata
)
33 os
.unlink(test_support
.TESTFN
)
41 def compareData(self
, isrf
, data
):
43 fp
= MacOS
.openrf(TESTFN2
, '*rb')
45 fp
= open(TESTFN2
, 'rb')
46 filedata
= fp
.read(1000)
47 self
.assertEqual(data
, filedata
)
49 def test_applesingle(self
):
54 applesingle
.decode(test_support
.TESTFN
, TESTFN2
)
55 self
.compareData(False, dataforkdata
)
56 self
.compareData(True, resourceforkdata
)
58 def test_applesingle_resonly(self
):
63 applesingle
.decode(test_support
.TESTFN
, TESTFN2
, resonly
=True)
64 self
.compareData(False, resourceforkdata
)
67 test_support
.run_unittest(TestApplesingle
)
70 if __name__
== '__main__':