# Copyright (C) 2003 Python Software Foundation
from test
import test_support
dataforkdata
= 'hello\r\0world\n'
resourceforkdata
= 'goodbye\ncruel\0world\r'
applesingledata
= struct
.pack("ll16sh", AS_MAGIC
, AS_VERSION
, "foo", 2) + \
struct
.pack("llllll", 1, 50, len(dataforkdata
),
2, 50+len(dataforkdata
), len(resourceforkdata
)) + \
TESTFN2
= test_support
.TESTFN
+ '2'
class TestApplesingle(unittest
.TestCase
):
fp
= open(test_support
.TESTFN
, 'w')
fp
.write(applesingledata
)
os
.unlink(test_support
.TESTFN
)
def compareData(self
, isrf
, data
):
fp
= MacOS
.openrf(TESTFN2
, '*rb')
self
.assertEqual(data
, filedata
)
def test_applesingle(self
):
applesingle
.decode(test_support
.TESTFN
, TESTFN2
)
self
.compareData(False, dataforkdata
)
self
.compareData(True, resourceforkdata
)
def test_applesingle_resonly(self
):
applesingle
.decode(test_support
.TESTFN
, TESTFN2
, resonly
=True)
self
.compareData(False, resourceforkdata
)
test_support
.run_unittest(TestApplesingle
)
if __name__
== '__main__':