Remove the Mac modules

This commit is contained in:
Benjamin Peterson 2008-05-12 22:25:16 +00:00
parent a005b34f14
commit 69a07fbd9b
288 changed files with 28 additions and 135614 deletions

View file

@ -1,84 +0,0 @@
# Copyright (C) 2003 Python Software Foundation
import unittest
import aepack
import aetypes
import os
from test import test_support
class TestAepack(unittest.TestCase):
OBJECTS = [
aetypes.Enum(b'enum'),
aetypes.Type(b'type'),
aetypes.Keyword(b'kwrd'),
aetypes.Range(1, 10),
aetypes.Comparison(1, b'< ', 10),
aetypes.Logical(b'not ', 1),
aetypes.IntlText(0, 0, b'international text'),
aetypes.IntlWritingCode(0,0),
aetypes.QDPoint(50,100),
aetypes.QDRectangle(50,100,150,200),
aetypes.RGBColor(0x7000, 0x6000, 0x5000),
aetypes.Unknown(b'xxxx', b'unknown type data'),
aetypes.Character(1),
aetypes.Character(2, aetypes.Line(2)),
]
def test_roundtrip_string(self):
o = 'a string'
packed = aepack.pack(o)
unpacked = aepack.unpack(packed)
self.assertEqual(o, unpacked)
def test_roundtrip_int(self):
o = 12
packed = aepack.pack(o)
unpacked = aepack.unpack(packed)
self.assertEqual(o, unpacked)
def test_roundtrip_float(self):
o = 12.1
packed = aepack.pack(o)
unpacked = aepack.unpack(packed)
self.assertEqual(o, unpacked)
def test_roundtrip_None(self):
o = None
packed = aepack.pack(o)
unpacked = aepack.unpack(packed)
self.assertEqual(o, unpacked)
def test_roundtrip_aeobjects(self):
for o in self.OBJECTS:
packed = aepack.pack(o)
unpacked = aepack.unpack(packed)
self.assertEqual(repr(o), repr(unpacked))
def test_roundtrip_FSSpec(self):
try:
import Carbon.File
except:
return
o = Carbon.File.FSSpec(os.curdir)
packed = aepack.pack(o)
unpacked = aepack.unpack(packed)
self.assertEqual(o.as_pathname(), unpacked.as_pathname())
def test_roundtrip_Alias(self):
try:
import Carbon.File
except:
return
o = Carbon.File.FSSpec(os.curdir).NewAliasMinimal()
packed = aepack.pack(o)
unpacked = aepack.unpack(packed)
self.assertEqual(o.FSResolveAlias(None)[0].as_pathname(),
unpacked.FSResolveAlias(None)[0].as_pathname())
def test_main():
test_support.run_unittest(TestAepack)
if __name__ == '__main__':
test_main()

View file

@ -1,71 +0,0 @@
# Copyright (C) 2003 Python Software Foundation
import unittest
import macostools
import Carbon.File
import MacOS
import os
from test import test_support
import struct
import applesingle
AS_MAGIC=0x00051600
AS_VERSION=0x00020000
dataforkdata = b'hello\r\0world\n'
resourceforkdata = b'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)) + \
dataforkdata + \
resourceforkdata
TESTFN2 = test_support.TESTFN + '2'
class TestApplesingle(unittest.TestCase):
def setUp(self):
fp = open(test_support.TESTFN, 'wb')
fp.write(applesingledata)
fp.close()
def tearDown(self):
try:
os.unlink(test_support.TESTFN)
except:
pass
try:
os.unlink(TESTFN2)
except:
pass
def compareData(self, isrf, data):
if isrf:
fp = MacOS.openrf(TESTFN2, '*rb')
else:
fp = open(TESTFN2, 'rb')
filedata = fp.read(1000)
self.assertEqual(data, filedata)
def test_applesingle(self):
try:
os.unlink(TESTFN2)
except:
pass
applesingle.decode(test_support.TESTFN, TESTFN2)
self.compareData(False, dataforkdata)
self.compareData(True, resourceforkdata)
def test_applesingle_resonly(self):
try:
os.unlink(TESTFN2)
except:
pass
applesingle.decode(test_support.TESTFN, TESTFN2, resonly=True)
self.compareData(False, resourceforkdata)
def test_main():
test_support.run_unittest(TestApplesingle)
if __name__ == '__main__':
test_main()

View file

@ -1,98 +0,0 @@
# Copyright (C) 2003 Python Software Foundation
import unittest
import macostools
import Carbon.File
import MacOS
import os
import sys
from test import test_support
TESTFN2 = test_support.TESTFN + '2'
class TestMacostools(unittest.TestCase):
def setUp(self):
fp = open(test_support.TESTFN, 'w')
fp.write('hello world\n')
fp.close()
rfp = MacOS.openrf(test_support.TESTFN, '*wb')
rfp.write('goodbye world\n')
rfp.close()
def tearDown(self):
try:
os.unlink(test_support.TESTFN)
except:
pass
try:
os.unlink(TESTFN2)
except:
pass
def compareData(self):
fp = open(test_support.TESTFN, 'r')
data1 = fp.read()
fp.close()
fp = open(TESTFN2, 'r')
data2 = fp.read()
fp.close()
if data1 != data2:
return 'Data forks differ'
rfp = MacOS.openrf(test_support.TESTFN, '*rb')
data1 = rfp.read(1000)
rfp.close()
rfp = MacOS.openrf(TESTFN2, '*rb')
data2 = rfp.read(1000)
rfp.close()
if data1 != data2:
return 'Resource forks differ'
return ''
def test_touched(self):
# This really only tests that nothing unforeseen happens.
import warnings
with test_support.catch_warning():
warnings.filterwarnings('ignore', 'macostools.touched*',
DeprecationWarning)
macostools.touched(test_support.TESTFN)
def test_copy(self):
try:
os.unlink(TESTFN2)
except:
pass
macostools.copy(test_support.TESTFN, TESTFN2)
self.assertEqual(self.compareData(), '')
def test_mkalias(self):
try:
os.unlink(TESTFN2)
except:
pass
macostools.mkalias(test_support.TESTFN, TESTFN2)
fss, _, _ = Carbon.File.ResolveAliasFile(TESTFN2, 0)
self.assertEqual(fss.as_pathname(), os.path.realpath(test_support.TESTFN))
def test_mkalias_relative(self):
try:
os.unlink(TESTFN2)
except:
pass
# If the directory doesn't exist, then chances are this is a new
# install of Python so don't create it since the user might end up
# running ``sudo make install`` and creating the directory here won't
# leave it with the proper permissions.
if not os.path.exists(sys.prefix):
return
macostools.mkalias(test_support.TESTFN, TESTFN2, sys.prefix)
fss, _, _ = Carbon.File.ResolveAliasFile(TESTFN2, 0)
self.assertEqual(fss.as_pathname(), os.path.realpath(test_support.TESTFN))
def test_main():
test_support.run_unittest(TestMacostools)
if __name__ == '__main__':
test_main()

View file

@ -1,49 +0,0 @@
# Copyright (C) 2003 Python Software Foundation
import unittest
from test import test_support
import aetools
class TestScriptpackages(unittest.TestCase):
def _test_scriptpackage(self, package, testobject=1):
# Check that we can import the package
mod = __import__(package)
# Test that we can get the main event class
klass = getattr(mod, package)
# Test that we can instantiate that class
talker = klass()
if testobject:
# Test that we can get an application object
obj = mod.application(0)
def test__builtinSuites(self):
self._test_scriptpackage('_builtinSuites', testobject=0)
def test_StdSuites(self):
self._test_scriptpackage('StdSuites')
def test_SystemEvents(self):
self._test_scriptpackage('SystemEvents')
def test_Finder(self):
self._test_scriptpackage('Finder')
def test_Terminal(self):
self._test_scriptpackage('Terminal')
def test_Netscape(self):
self._test_scriptpackage('Netscape')
def test_Explorer(self):
self._test_scriptpackage('Explorer')
def test_CodeWarrior(self):
self._test_scriptpackage('CodeWarrior')
def test_main():
test_support.run_unittest(TestScriptpackages)
if __name__ == '__main__':
test_main()