Commits

Ronald Oussoren committed 907e956

This moves the testcases from objc.test to
PyObjCTest. The latter package is not installed.

Comments (0)

Files changed (140)

pyobjc-core/Lib/objc/test/__init__.py

-"""
-objc.test package - unittests for the pyobjc core
-"""

pyobjc-core/Lib/objc/test/fnd.py

-"""
-Dummy Foundation wrappers, just those parts needed for the unittests.
-"""
-import objc as _objc
-
-__bundle__ = _objc.loadBundle(
-        'Foundation',
-        globals(),
-        bundle_identifier=u'com.apple.Foundation',
-)
-
-_objc.loadBundleVariables(__bundle__, globals(), [
-            ( 'NSPriorDayDesignations', _objc._C_ID ),
-        ])
-
-NSPropertyListXMLFormat_v1_0 = 100
-NSKeyValueObservingOptionNew = 0x01
-NSKeyValueObservingOptionOld = 0x02

pyobjc-core/Lib/objc/test/keyvaluehelper.py

-"""
-Helper module for KeyValue tests
-"""
-from objc.test.testbndl import PyObjCTest_KVBaseClass, PyObjCTest_KVPathClass
-import objc
-
-NSObject = objc.lookUpClass('NSObject')
-
-DirectString = u'Direct String'
-IndirectString = u'Indirect String'
-DirectNumber = 42
-IndirectNumber = 84
-
-class KVPyBase:
-    def __init__(self):
-        self.directString = DirectString
-        self._indirectString = IndirectString
-        self.directNumber = DirectNumber
-        self._indirectNumber = IndirectNumber
-
-    def get_indirectString(self):
-        return self._indirectString
-
-    def set_indirectString(self, aString):
-        self._indirectString = aString
-
-    def getIndirectNumber(self):
-        return self._indirectNumber
-
-    def setIndirectNumber(self, aNumber):
-        self._indirectNumber = aNumber
-
-class KVPyPath:
-    def __init__(self):
-        self.directHead = KVPyBase()
-        self._indirectHead = KVPyBase()
-
-    def indirectHead(self):
-        return self._indirectHead
-
-    def setIndirectHead(self, aHead):
-        self._indirectHead = aHead
-
-class KVPySubObjCBase (PyObjCTest_KVBaseClass):
-    pass
-
-class KVPySubObjCPath (PyObjCTest_KVPathClass):
-    pass
-
-class KVPySubOverObjCBase (PyObjCTest_KVBaseClass):
-    def init(self):
-        self = super(KVPySubOverObjCBase, self).init()
-        if not self:
-            return self
-
-        self.overDirectString = DirectString
-        self._overIndirectString = IndirectString
-        return self
-
-    def getOverIndirectString(self):
-        return self._overIndirectString
-
-    def setOverIndirectString_(self, aString):
-        self._overIndirectString = aString
-
-class KVPySubOverObjCPath(PyObjCTest_KVPathClass):
-    def init(self):
-        self = super(KVPySubOverObjCPath, self).init()
-        self.overDirectHead = KVPySubOverObjCBase.new()
-        self._overIndirectHead = KVPySubOverObjCBase.new()
-        return self
-
-    def overIndirectHead(self):
-        return self._overIndirectHead
-
-    def setOverIndirectHead_(self, aHead):
-        self._overIndirectHead = aHead
-
-class PyObjCTestObserver (NSObject):
-    def init(self):
-        self = super(PyObjCTestObserver, self).init()
-        if self is not None:
-            self.observed = []
-            self.willChange = []
-        return self
-
-    def observeValueForKeyPath_ofObject_change_context_(self, keyPath, obj, change, context):
-        self.observed.append( (keyPath, obj, change, context) )
-
-    def willChangeValueForKey_(self, key):
-        self.willChange.append(key)

pyobjc-core/Lib/objc/test/test_NULL.py

-from PyObjCTools.TestSupport import *
-import objc
-
-setSignature = objc.setSignatureForSelector
-#setSignature("OCTestNULL", "callOut:", "i@:o^i")
-#setSignature("OCTestNULL", "callList:andInOut2:", "i@:@^i")
-#setSignature("OCTestNULL", "callList:andInOut:", "i@:@N^i")
-#setSignature("OCTestNULL", "callList:andIn:", "i@:@n^i")
-#setSignature("OCTestNULL", "callList:andOut:", "i@:@o^i")
-#setSignature("OCTestNULL", "on:callList:andInOut:", "i@:@@N^i")
-#setSignature("OCTestNULL", "on:callList:andIn:", "i@:@@n^i")
-#setSignature("OCTestNULL", "on:callList:andOut:", "i@:@@N^i") # 'N' is by design
-#setSignature("OCTestNULL", "on:callOut:", "v@:@N^i") # 'N' is by design
-
-objc.registerMetaDataForSelector( "OCTestNULL", "callOut:", dict(
-            arguments={
-                2: dict(type_modifier='o', null_accepted=True),
-            },
-        ))
-objc.registerMetaDataForSelector("OCTestNULL", "callList:andInOut2:", dict(
-            arguments={
-                3: dict(type_modifier='o', null_accepted=True),
-            },
-        ))
-objc.registerMetaDataForSelector("OCTestNULL", "callList:andInOut:", dict(
-            arguments={
-                3: dict(type_modifier='N', null_accepted=True),
-            },
-        ))
-objc.registerMetaDataForSelector("OCTestNULL", "callList:andIn:", dict(
-            arguments={
-                3: dict(type_modifier='n', null_accepted=True),
-            },
-        ))
-objc.registerMetaDataForSelector("OCTestNULL", "callList:andOut:", dict(
-            arguments={
-                3: dict(type_modifier='o', null_accepted=True),
-            },
-        ))
-objc.registerMetaDataForSelector("OCTestNULL", "on:callList:andInOut:", dict(
-            arguments={
-                4: dict(type_modifier='N', null_accepted=True),
-            },
-        ))
-objc.registerMetaDataForSelector("OCTestNULL", "on:callList:andIn:", dict(
-            arguments={
-                4: dict(type_modifier='n', null_accepted=True),
-            },
-        ))
-objc.registerMetaDataForSelector("OCTestNULL", "on:callList:andOut:", dict(
-            arguments={
-                4: dict(type_modifier='N', null_accepted=True), # N is by design
-            },
-        ))
-objc.registerMetaDataForSelector("OCTestNULL", "on:callOut:", dict(
-            arguments={
-                3: dict(type_modifier='N', null_accepted=True), # N is by design
-            },
-        ))
-
-from objc.test.NULL import *
-
-class TestNULL (TestCase):
-    def testNULL(self):
-        self.assert_(hasattr(objc, 'NULL'))
-        self.assertEquals(repr(objc.NULL), 'objc.NULL')
-        self.assertRaises(TypeError, type(objc.NULL))
-
-
-class TestNullArgumentsHelper (objc.lookUpClass("NSObject")):
-
-    def callList_andInOut_(self, lst, value):
-        lst.append(str(value))
-        if value is objc.NULL:
-            return (13, value)
-        else:
-            return (13, value * 2)
-
-    callList_andInOut_ = objc.selector(callList_andInOut_,
-            signature="i@:@N^i")
-
-    def callList_andInOut2_(self, lst, value):
-        lst.append(repr(value))
-        if value is objc.NULL:
-            return 29
-        else:
-            return 29
-    callList_andInOut2_ = objc.selector(callList_andInOut2_,
-            signature="i@:@^i")
-
-    def callList_andIn_(self, lst, value):
-        lst.append(repr(value))
-        return 26
-
-    callList_andIn_ = objc.selector(callList_andIn_,
-            signature="i@:@n^i")
-
-    def callList_andOut_(self, lst, value):
-        assert value is None or value is objc.NULL
-        lst.append("Nothing here")
-        return (27, 99)
-    callList_andOut_ = objc.selector(callList_andOut_,
-            signature="i@:@o^i")
-
-    def callOut_(self, value):
-        assert value is None or value is objc.NULL
-        return 441;
-    callOut_ = objc.selector(callOut_, signature='v@:o^i')    
-
-class TestNULLArguments (TestCase):
-    def testCallInOutNULL(self):
-        obj = OCTestNULL.alloc().init()
-
-        v = []
-        rv = obj.callList_andInOut_(v, 42)
-        self.assertEquals(v, ["42"])
-        self.assertEquals(rv, (12, 21))
-
-        v = []
-        rv = obj.callList_andInOut_(v, objc.NULL)
-        self.assertEquals(v, ["NULL"])
-        self.assertEquals(rv,  (12, objc.NULL))
-
-    def testCallInOutNULL2(self):
-        # If nothing is specified the bridge assumes the argument behaves
-        # like an 'in' argument.
-
-        obj = OCTestNULL.alloc().init()
-
-        v = []
-        self.assertRaises(ValueError, obj.callList_andInOut2_, v, 42)
-        self.assertEquals(v, [])
-
-        v = []
-        rv = obj.callList_andInOut2_(v, objc.NULL)
-        self.assertEquals(v, ["NULL"])
-        self.assertEquals(rv,  (12, objc.NULL))
-
-    def testCallInNULL(self):
-        obj = OCTestNULL.alloc().init()
-
-        v = []
-        rv = obj.callList_andIn_(v, 42)
-        self.assertEquals(v, ["42"])
-        self.assertEquals(rv, 24)
-
-        v = []
-        rv = obj.callList_andIn_(v, objc.NULL)
-        self.assertEquals(v, ["NULL"])
-        self.assertEquals(rv,  24)
-
-
-    def testCalledInOutNULL(self):
-        helper = OCTestNULL.alloc().init()
-        obj = TestNullArgumentsHelper.alloc().init()
-
-        v = []
-        rv = helper.on_callList_andInOut_(obj, v, 42)
-        self.assertEquals(v, ['42'])
-        self.assertEquals(rv, (13, 84))
-
-        v = []
-        rv = helper.on_callList_andInOut_(obj, v, objc.NULL)
-        self.assertEquals(v, ['objc.NULL'])
-        self.assertEquals(rv, (13, objc.NULL))
-
-    def testCalledInNULL(self):
-        helper = OCTestNULL.alloc().init()
-        obj = TestNullArgumentsHelper.alloc().init()
-
-        v = []
-        rv = helper.on_callList_andIn_(obj, v, 42)
-        self.assertEquals(v, ['42'])
-        self.assertEquals(rv, 26)
-
-        v = []
-        rv = helper.on_callList_andIn_(obj, v, objc.NULL)
-        self.assertEquals(v, ['objc.NULL'])
-        self.assertEquals(rv, 26)
-
-    def testCalledOutNULL(self):
-
-        helper = OCTestNULL.alloc().init()
-        obj = TestNullArgumentsHelper.alloc().init()
-
-        v = []
-        rv = helper.on_callList_andOut_(obj, v, 42)
-        self.assertEquals(v, ['Nothing here'])
-        self.assertEquals(rv, (27, 99))
-
-        v = []
-        rv = helper.on_callList_andOut_(obj, v, objc.NULL)
-        self.assertEquals(v, ['Nothing here'])
-        self.assertEquals(rv, (27, objc.NULL))
-
-        rv = helper.on_callOut_(obj, 42)
-        self.assertEquals(rv, 441)
-
-        rv = helper.on_callOut_(obj, objc.NULL)
-        self.assertEquals(rv, objc.NULL)
-
-    def dont_testCalledOutNULL(self):
-        """
-        XXX: I'm not happy about these semantics!
-
-        Current semantics: called method doesn't know about the NULL argument,
-        the result from Python is ignored.
-
-        New semantics:
-        - If the last argument is 'out' use new semantics, otherwise keep
-          current semantics
-        - If function has an optional last param stuf this with objc.NULL if
-          the argument is NULL, otherwise don't provide
-        - If the functioin has a required last param: stuff with objc.NULL or
-          None
-        """
-
-
-    def dont_testCallOutNULL(self):
-        """
-        Call a method with an 'out' argument with an additional method
-
-        - if not objc.NULL: raise TypeError
-        - argument should be NULL in objC
-        - result should be objc.NULL
-        """
-
-        
-
-
-if __name__ == "__main__":
-    main()

pyobjc-core/Lib/objc/test/test_allocatebuffer.py

-from PyObjCTools.TestSupport import *
-
-import objc
-
-class TestAllocateBuffer(TestCase):
-    def testBadLengths(self):
-        self.assertRaises(ValueError, objc.allocateBuffer, 0)
-        self.assertRaises(ValueError, objc.allocateBuffer, -1000)
-
-    def testBuffer(self):
-        b = objc.allocateBuffer(10000)
-        self.assertEquals(len(b), 10000)
-
-        for i in range(0,10000):
-            b[i] = chr(i % 256)
-
-        b[5:10] = b[1:6]
-        b[5:10] = 'abcde'
-        try:
-            b[5:10] = 'abcdefghijk'
-        except TypeError, r:
-            if str(r).find("right operand length must match slice length") is not 0:
-                raise
-
-if __name__ == '__main__':
-    main()
-    objc.recycleAutoreleasePool()

pyobjc-core/Lib/objc/test/test_archive_python.py

-"""
-Testcases for NSArchive-ing python objects.
-
-(Implementation is incomplete)
-"""
-import os
-
-import sys, copy_reg
-
-from PyObjCTools.TestSupport import *
-
-from objc.test.fnd import NSArchiver, NSUnarchiver
-from objc.test.fnd import NSKeyedArchiver, NSKeyedUnarchiver
-from objc.test.fnd import NSData, NSArray, NSDictionary
-from objc.test.fnd import NSMutableArray, NSMutableDictionary
-
-
-# 
-# First set of tests: the stdlib tests for pickling, this
-# should test everything but mixed Python/Objective-C 
-# object-graphs.
-#
-
-import test.pickletester
-
-MyList = test.pickletester.MyList
-
-# Quick hack to add a proper __repr__ to class C in
-# pickletester, makes it a lot easier to debug.
-def C__repr__(self):
-    return '<%s instance at %#x: %r>'%(
-        self.__class__.__name__, id(self), self.__dict__)
-test.pickletester.C.__repr__ = C__repr__
-del C__repr__
-
-def a_function():
-    pass
-
-class a_classic_class:
-    pass
-
-class a_newstyle_class (object):
-    pass
-
-def make_instance(state):
-    o = a_reducing_class()
-    o.__dict__.update(state)
-    return o
-
-class a_reducing_class (object):
-    def __reduce__(self):
-        return make_instance, (self.__dict__,)
-
-
-if int(os.uname()[2].split('.')[0]) >= 9:
-
-    # For some reason NSCoding support doesn't work on OSX 10.4 yet, ignore these
-    # tests for now
-    class TestKeyedArchiveSimple (TestCase):
-        def testBasicObjects(self):
-            buf = NSKeyedArchiver.archivedDataWithRootObject_(a_function)
-            self.assert_(isinstance(buf, NSData))
-            v = NSKeyedUnarchiver.unarchiveObjectWithData_(buf)
-            self.assert_(v is a_function)
-
-            buf = NSKeyedArchiver.archivedDataWithRootObject_(a_classic_class)
-            self.assert_(isinstance(buf, NSData))
-            v = NSKeyedUnarchiver.unarchiveObjectWithData_(buf)
-            self.assert_(v is a_classic_class)
-
-            buf = NSKeyedArchiver.archivedDataWithRootObject_(a_newstyle_class)
-            self.assert_(isinstance(buf, NSData))
-            v = NSKeyedUnarchiver.unarchiveObjectWithData_(buf)
-            self.assert_(v is a_newstyle_class)
-
-            o = a_classic_class()
-            o.x = 42
-            buf = NSKeyedArchiver.archivedDataWithRootObject_(o)
-            self.assert_(isinstance(buf, NSData))
-            v = NSKeyedUnarchiver.unarchiveObjectWithData_(buf)
-            self.assert_(isinstance(v, a_classic_class))
-            self.assertEquals(o.x, 42)
-
-            buf = NSKeyedArchiver.archivedDataWithRootObject_(u"hello")
-            self.assert_(isinstance(buf, NSData))
-            v = NSKeyedUnarchiver.unarchiveObjectWithData_(buf)
-            self.assert_(isinstance(v, unicode))
-
-            buf = NSKeyedArchiver.archivedDataWithRootObject_("hello")
-            self.assert_(isinstance(buf, NSData))
-            v = NSKeyedUnarchiver.unarchiveObjectWithData_(buf)
-            self.assert_(isinstance(v, str))
-            self.assertEquals(v, "hello")
-
-            buf = NSKeyedArchiver.archivedDataWithRootObject_(sys.maxint * 4)
-            self.assert_(isinstance(buf, NSData))
-            v = NSKeyedUnarchiver.unarchiveObjectWithData_(buf)
-            self.assert_(isinstance(v, long))
-            self.assertEquals(v, sys.maxint * 4)
-
-            buf = NSKeyedArchiver.archivedDataWithRootObject_(sys.maxint ** 4)
-            self.assert_(isinstance(buf, NSData))
-            v = NSKeyedUnarchiver.unarchiveObjectWithData_(buf)
-            self.assert_(isinstance(v, long))
-            self.assertEquals(v, sys.maxint ** 4)
-
-        def testSimpleLists(self):
-            o = []
-            buf = NSKeyedArchiver.archivedDataWithRootObject_(o)
-            self.assert_(isinstance(buf, NSData))
-            v = NSKeyedUnarchiver.unarchiveObjectWithData_(buf)
-            self.assert_(isinstance(v, list))
-            self.assertEquals(v, o)
-
-            o = [u"hello", 42]
-            buf = NSKeyedArchiver.archivedDataWithRootObject_(o)
-            self.assert_(isinstance(buf, NSData))
-            v = NSKeyedUnarchiver.unarchiveObjectWithData_(buf)
-            self.assert_(isinstance(v, list))
-            self.assertEquals(v, o)
-
-        def testSimpleTuples(self):
-            o = ()
-            buf = NSKeyedArchiver.archivedDataWithRootObject_(o)
-            self.assert_(isinstance(buf, NSData))
-            v = NSKeyedUnarchiver.unarchiveObjectWithData_(buf)
-            self.assert_(isinstance(v, tuple))
-            self.assertEquals(v, o)
-
-            o = (u"hello", 42)
-            buf = NSKeyedArchiver.archivedDataWithRootObject_(o)
-            self.assert_(isinstance(buf, NSData))
-            v = NSKeyedUnarchiver.unarchiveObjectWithData_(buf)
-            self.assert_(isinstance(v, tuple))
-            self.assertEquals(v, o)
-
-        def testSimpleDicts(self):
-            o = {}
-            buf = NSKeyedArchiver.archivedDataWithRootObject_(o)
-            self.assert_(isinstance(buf, NSData))
-            v = NSKeyedUnarchiver.unarchiveObjectWithData_(buf)
-            self.assert_(isinstance(v, dict))
-            self.assertEquals(v, o)
-
-            o = {u"hello": u"bar", 42: 1.5 }
-            buf = NSKeyedArchiver.archivedDataWithRootObject_(o)
-            self.assert_(isinstance(buf, NSData))
-            v = NSKeyedUnarchiver.unarchiveObjectWithData_(buf)
-            self.assert_(isinstance(v, dict))
-            self.assertEquals(v, o)
-
-        def testNestedDicts(self):
-            o = {
-                    u"hello": { 1:2 },
-                    u"world": u"foobar"
-                }
-            buf = NSKeyedArchiver.archivedDataWithRootObject_(o)
-            self.assert_(isinstance(buf, NSData))
-            v = NSKeyedUnarchiver.unarchiveObjectWithData_(buf)
-            self.assert_(isinstance(v, dict))
-            self.assertEquals(v, o)
-
-            o = {}
-            o[u'self'] = o
-            buf = NSKeyedArchiver.archivedDataWithRootObject_(o)
-            self.assert_(isinstance(buf, NSData))
-            v = NSKeyedUnarchiver.unarchiveObjectWithData_(buf)
-            self.assert_(isinstance(v, dict))
-            self.assert_(v[u'self'] is v)
-
-        def testNestedSequences(self):
-            o = [ 1, 2, 3, (5, (u'a', u'b'), 6), {1:2} ]
-            o[-1] = o
-
-            buf = NSKeyedArchiver.archivedDataWithRootObject_(o)
-            self.assert_(isinstance(buf, NSData))
-            v = NSKeyedUnarchiver.unarchiveObjectWithData_(buf)
-            self.assert_(isinstance(v, list))
-            self.assert_(v[-1] is v)
-            self.assertEquals(v[:-1], o[:-1])
-
-        def testNestedInstance(self):
-            o = a_classic_class()
-            o.value = o
-
-            buf = NSKeyedArchiver.archivedDataWithRootObject_(o)
-            self.assert_(isinstance(buf, NSData))
-            v = NSKeyedUnarchiver.unarchiveObjectWithData_(buf)
-
-            self.assert_(isinstance(v, a_classic_class))
-            self.assert_(v.value is v)
-
-        def dont_testNestedInstanceWithReduce(self):
-            # Test recursive instantation with a __reduce__ method
-            #
-            # This test is disabled because pickle doesn't support
-            # this (and we don't either)
-            o = a_reducing_class()
-            o.value = o
-
-            import pickle
-            b = pickle.dumps(o)
-            o2 = picle.loads(b)
-            print "+++", o2.value is o2
-
-            buf = NSKeyedArchiver.archivedDataWithRootObject_(o)
-            self.assert_(isinstance(buf, NSData))
-            v = NSKeyedUnarchiver.unarchiveObjectWithData_(buf)
-
-            self.assert_(isinstance(v, a_reducing_class))
-            print type(v.value)
-            print v.value
-            print v
-            self.assert_(v.value is v)
-
-        def testRecusiveNesting(self):
-            l = []
-            d = {1:l}
-            i = a_classic_class()
-            i.attr = d
-            l.append(i)
-
-            buf = NSKeyedArchiver.archivedDataWithRootObject_(l)
-            self.assert_(isinstance(buf, NSData))
-            v = NSKeyedUnarchiver.unarchiveObjectWithData_(buf)
-
-            self.assertEquals(len(v), 1)
-            self.assertEquals(dir(v[0]), dir(i))
-            self.assertEquals(v[0].attr.keys(), [1])
-            self.assert_(v[0].attr[1] is v)
-
-            buf = NSKeyedArchiver.archivedDataWithRootObject_(d)
-            self.assert_(isinstance(buf, NSData))
-            v = NSKeyedUnarchiver.unarchiveObjectWithData_(buf)
-            self.assert_(v[1][0].attr is v)
-            
-
-
-        def testTupleOfObjects(self):
-            o = a_classic_class()
-            t = (o, o, o)
-
-            buf = NSKeyedArchiver.archivedDataWithRootObject_(t)
-            self.assert_(isinstance(buf, NSData))
-            v = NSKeyedUnarchiver.unarchiveObjectWithData_(buf)
-
-            self.assert_(isinstance(v, tuple))
-            self.assert_(len(v) == 3)
-            self.assert_(isinstance(v[0], a_classic_class))
-            self.assert_(v[0] is v[1])
-            self.assert_(v[0] is v[2])
-
-
-
-    class TestKeyedArchivePlainPython (TestCase, test.pickletester.AbstractPickleTests):
-        # Ensure that we don't run every test case three times
-        def setUp(self):
-            self._protocols = test.pickletester.protocols
-            test.pickletester.protocols = (2,)
-
-        def tearDown(self):
-            test.pickletester.protoocols = self._protocols
-
-
-        def dumps(self, arg, proto=0, fast=0):
-            # Ignore proto and fast
-            return NSKeyedArchiver.archivedDataWithRootObject_(arg)
-
-        def loads(self, buf):
-            return NSKeyedUnarchiver.unarchiveObjectWithData_(buf)
-
-        
-        # Disable a number of methods, these test things we're not interested in.
-        # (Most of these look at the generated byte-stream, as we're not writing data in pickle's
-        # format such tests are irrelevant to archiving support)
-        def test_insecure_strings(self): pass
-        def test_load_from_canned_string(self): pass
-        def test_maxint64(self): pass
-        def test_dict_chunking(self): pass
-        def test_float_format(self): pass
-        def test_garyp(self): pass
-        def test_list_chunking(self): pass
-        def test_singletons(self): pass
-        def test_simple_newobj(self): pass
-        def test_short_tuples(self): pass
-        def test_proto(self): pass
-        def test_long1(self): pass
-        def test_long4(self): pass
-
-
-        def test_long(self):
-            # The real test_long method takes way to much time, test a subset
-            x = 12345678910111213141516178920L << (256*8)
-            buf = self.dumps(x)
-            v = self.loads(buf)
-            self.assertEquals(v, x)
-
-            x = -x
-
-            buf = self.dumps(x)
-            v = self.loads(buf)
-
-            self.assertEquals(v, x)
-
-            for val in (0L, 1L, long(sys.maxint), long(sys.maxint * 128)):
-                for x in val, -val:
-                    buf = self.dumps(x)
-                    v = self.loads(buf)
-                    self.assertEquals(v, x)
-
-
-
-
-
-        # Overriden tests for extension codes, the test code checks
-        # the actual byte stream.
-        def produce_global_ext(self, extcode, opcode):
-            e = test.pickletester.ExtensionSaver(extcode)
-            try:
-                copy_reg.add_extension(__name__, "MyList", extcode)
-                x = MyList([1, 2, 3])
-                x.foo = 42
-                x.bar = "hello"
-
-                s1 = self.dumps(x, 1)
-                y = self.loads(s1)
-                self.assertEqual(list(x), list(y))
-                self.assertEqual(x.__dict__, y.__dict__)
-            finally:
-                e.restore()
-
-        #
-        # The test_reduce* methods iterate over various protocol
-        # versions. Override to only look at protocol version 2.
-        #
-        def test_reduce_overrides_default_reduce_ex(self):
-            for proto in 2,: 
-                x = test.pickletester.REX_one()
-                self.assertEqual(x._reduce_called, 0)
-                s = self.dumps(x, proto)
-                self.assertEqual(x._reduce_called, 1)
-                y = self.loads(s)
-                self.assertEqual(y._reduce_called, 0)
-
-        def test_reduce_ex_called(self):
-            for proto in 2,: 
-                x = test.pickletester.REX_two()
-                self.assertEqual(x._proto, None)
-                s = self.dumps(x, proto)
-                self.assertEqual(x._proto, proto)
-                y = self.loads(s)
-                self.assertEqual(y._proto, None)
-
-        def test_reduce_ex_overrides_reduce(self):
-            for proto in 2,:
-                x = test.pickletester.REX_three()
-                self.assertEqual(x._proto, None)
-                s = self.dumps(x, proto)
-                self.assertEqual(x._proto, proto)
-                y = self.loads(s)
-                self.assertEqual(y._proto, None)
-
-        def test_reduce_ex_calls_base(self):
-            for proto in 2,:
-                x = test.pickletester.REX_four()
-                self.assertEqual(x._proto, None)
-                s = self.dumps(x, proto)
-                self.assertEqual(x._proto, proto)
-                y = self.loads(s)
-                self.assertEqual(y._proto, proto)
-
-        def test_reduce_calls_base(self):
-            for proto in 2,:
-                x = test.pickletester.REX_five()
-                self.assertEqual(x._reduce_called, 0)
-                s = self.dumps(x, proto)
-                self.assertEqual(x._reduce_called, 1)
-                y = self.loads(s)
-                self.assertEqual(y._reduce_called, 1)
-
-
-    #
-    # Disable testing of plain Archiving for now, need full support
-    # for keyed-archiving first, then worry about adding "classic"
-    # archiving.
-    # 
-    #class TestArchivePlainPython (TestKeyedArchivePlainPython):
-    #    def dumps(self, arg, proto=0, fast=0):
-    #        # Ignore proto and fast
-    #        return NSArchiver.archivedDataWithRootObject_(arg)
-    #
-    #    def loads(self, buf):
-    #        return NSUnarchiver.unarchiveObjectWithData_(buf)
-
-
-    # 
-    # Second set of tests: test if archiving a graph that
-    # contains both python and objective-C objects works correctly.
-    #
-    class TestKeyedArchiveMixedGraphs (TestCase):
-        def dumps(self, arg, proto=0, fast=0):
-            # Ignore proto and fast
-            return NSKeyedArchiver.archivedDataWithRootObject_(arg)
-
-        def loads(self, buf):
-            return NSKeyedUnarchiver.unarchiveObjectWithData_(buf)
-
-        def test_list1(self):
-            o1 = a_classic_class()
-            o2 = a_newstyle_class()
-            o2.lst = NSArray.arrayWithObject_(o1)
-            l = NSArray.arrayWithArray_([o1, o2, [o1, o2]])
-
-            buf = self.dumps(l)
-            self.assert_(isinstance(buf, NSData))
-
-            out = self.loads(buf)
-            self.assert_(isinstance(out, NSArray))
-            self.assertEquals(len(out), 3)
-
-            p1 = out[0]
-            p2 = out[1]
-            p3 = out[2]
-
-            self.assert_(isinstance(p1, a_classic_class))
-            self.assert_(isinstance(p2, a_newstyle_class))
-            self.assert_(isinstance(p3, list))
-            self.assert_(p3[0] is p1)
-            self.assert_(p3[1] is p2)
-            self.assert_(isinstance(p2.lst , NSArray))
-            self.assert_(p2.lst[0] is p1)
-           
-
-
-
-
-    #
-    # And finally some tests to check if archiving of Python
-    # subclasses of NSObject works correctly.
-    #
-    class TestArchivePythonObjCSubclass (TestCase):
-        pass
-
-if __name__ == "__main__":
-    main()

pyobjc-core/Lib/objc/test/test_arrays.py

-"""
-Some tests for arrays in method arguments (the 'int foo[4]' type of array).
-
-This tests both calling such methods, as well as implementing methods with such arguments.
-"""
-from PyObjCTools.TestSupport import *
-import objc
-import array
-from objc.test.arrays import *
-from objc.test.fnd import NSObject
-
-
-class TestArrayCalling (TestCase):
-    def testArrayOfInts(self):
-        o = OC_ArrayTest.alloc().init()
-
-        v = o.arrayOf4Ints_([0, 1, 2, 3])
-        self.assertEquals(v, [0, 1, 2, 3])
-
-        a = array.array('i', [9, 10, 11, 12])
-        v = o.arrayOf4Ints_(a)
-        self.assertEquals(v, [9, 10, 11, 12])
-
-    def testArrayOfIntsIn(self):
-        o = OC_ArrayTest.alloc().init()
-
-        v = o.arrayOf4IntsIn_([0, 1, 2, 3])
-        self.assertEquals(v, [0, 1, 2, 3])
-
-        a = array.array('i', [9, 10, 11, 12])
-        v = o.arrayOf4IntsIn_(a)
-        self.assertEquals(v, [9, 10, 11, 12])
-
-    def testArrayOfIntsInOut(self):
-        o = OC_ArrayTest.alloc().init()
-
-        v, r = o.arrayOf4IntsInOut_([0, 1, 2, 3])
-        self.assertEquals(v, (0, 1, 2, 3))
-        self.assertEquals(r, (0+42, 1+42, 2+42, 3+42))
-
-        a = array.array('i', [9, 10, 11, 12])
-        v, r = o.arrayOf4IntsInOut_(a)
-        self.assertEquals(v, [9, 10, 11, 12])
-        self.assert_(r is a)
-        self.assertEquals(a[0], 9 + 42)
-        self.assertEquals(a[1], 10 + 42)
-        self.assertEquals(a[2], 11 + 42)
-        self.assertEquals(a[3], 12 + 42)
-
-    def testArrayOfIntsOut(self):
-        o = OC_ArrayTest.alloc().init()
-
-        v = o.arrayOf4IntsOut_(None)
-        self.assertEquals(v, (99, 100, 102, 110))
-
-        a = array.array('i', [9, 10, 11, 12])
-        v = o.arrayOf4IntsOut_(a)
-        self.assert_(a is v)
-        self.assertEquals(a[0], 99)
-        self.assertEquals(a[1], 100)
-        self.assertEquals(a[2], 102)
-        self.assertEquals(a[3], 110)
-
-    def testArrayOfStructs(self):
-        o = OC_ArrayTest.alloc().init()
-
-        v = o.arrayOf4Structs_([(0, 1), (10, 20), (-10, -20), (7, 8)])
-        self.assertEquals(v, [(0, 1), (10, 20), (-10, -20), (7, 8)])
-
-        a = array.array('i', [9, 10, 11, 12, -1, -2, -3, -4])
-        v = o.arrayOf4Structs_(a)
-        self.assertEquals(v, [(9, 10), (11, 12), (-1, -2), (-3, -4)])
-
-    def testArrayOfStructsIn(self):
-        o = OC_ArrayTest.alloc().init()
-
-        v = o.arrayOf4StructsIn_([(0, 1), (2, 3), (-1, -2), (-3, -4)])
-        self.assertEquals(v, [(0, 1), (2, 3), (-1, -2), (-3, -4)])
-
-        a = array.array('i', [9, 10, 11, 12, -1, -2, -3, -4])
-        v = o.arrayOf4StructsIn_(a)
-        self.assertEquals(v, [(9, 10), (11, 12), (-1, -2), (-3, -4)])
-
-    def testArrayOfStructsInOut(self):
-        o = OC_ArrayTest.alloc().init()
-
-        v, r = o.arrayOf4StructsInOut_([(0, 1), (2, 3), (4, 5), (6,7)])
-        self.assertEquals(v, ((0,1), (2,3), (4,5), (6,7)))
-        self.assertEquals(r, ((0+42, 1-42), (2+42,3-42), (4+42, 5-42), (6+42, 7-42)))
-
-        a = array.array('i', [9, 10, 11, 12, 14, 15, 16, 17])
-        v, r = o.arrayOf4StructsInOut_(a)
-        self.assertEquals(v, [(9, 10), (11, 12), (14, 15), (16, 17)])
-        self.assert_(r is a)
-        self.assertEquals(a[0], 9 + 42)
-        self.assertEquals(a[1], 10 - 42)
-        self.assertEquals(a[2], 11 + 42)
-        self.assertEquals(a[3], 12 - 42)
-        self.assertEquals(a[4], 14 + 42)
-        self.assertEquals(a[5], 15 - 42)
-        self.assertEquals(a[6], 16 + 42)
-        self.assertEquals(a[7], 17 - 42)
-
-    def testArrayOfStructsOut(self):
-        o = OC_ArrayTest.alloc().init()
-
-        v = o.arrayOf4StructsOut_(None)
-        self.assertEquals(list(v), [ (1+i*i, -4 - i*i*i) for i in range(4) ])
-
-        a = array.array('i', [0]*8)
-        v = o.arrayOf4StructsOut_(a)
-        self.assert_(a is v)
-        l = []
-        for i in range(4):
-            l.append(1 + i * i)
-            l.append(-4 - i * i * i)
-        self.assertEquals(a[0], l[0])
-        self.assertEquals(a[1], l[1])
-        self.assertEquals(a[2], l[2])
-        self.assertEquals(a[3], l[3])
-        self.assertEquals(a[4], l[4])
-        self.assertEquals(a[5], l[5])
-        self.assertEquals(a[6], l[6])
-        self.assertEquals(a[7], l[7])
-
-StructArrayDelegate = objc.informal_protocol(
-    "ArrayDelegate",
-    [
-        objc.selector(None, "arrayOf4Ints:", signature="@@:[4i]", isRequired=False),
-        objc.selector(None, "arrayOf4IntsOut:", signature="v@:o[4i]", isRequired=False),
-        objc.selector(None, "arrayOf4Structs:", signature="@@:[4{FooStruct=ii}]", isRequired=False),
-        objc.selector(None, "arrayOf4StructsOut:", signature="v@:o[4{FooStruct=ii}]", isRequired=False),
-    ]
-)
-
-class OC_TestArrayInt_In (NSObject):
-    def arrayOf4Ints_(self, array):
-        return array
-
-class OC_TestArrayInt_Out (NSObject):
-    def arrayOf4IntsOut_(self, array):
-        if array is None:
-            return [ 99, 100, 98, 101 ]
-
-class OC_TestArrayStruct_Out (NSObject):
-    def arrayOf4StructsOut_(self, array):
-        if array is None:
-            return [ (44, 45), (46, 47), (48, 49), (50, 51) ]
-
-class OC_TestArrayStruct_In (NSObject):
-    def arrayOf4Structs_(self, array):
-        return array
-
-class TestArrayCallbacks (TestCase):
-    def testCallArrayInt(self):
-
-        obj = OC_TestArrayInt_In.alloc().init()
-
-        v = OC_ArrayTest.callArrayOf4Ints_(obj)
-        self.assertEquals(v, (1, 2, 3, 4))
-
-    def testCallArrayIntsOut(self):
-
-        obj = OC_TestArrayInt_Out.alloc().init()
-
-        v = OC_ArrayTest.callArrayOf4IntsOut_(obj)
-        self.assertEquals(v, [99, 100, 98, 101])
-
-    def testCallArrayStruct(self):
-
-        obj = OC_TestArrayStruct_In.alloc().init()
-
-        v = OC_ArrayTest.callArrayOf4Structs_(obj)
-        self.assertEquals(v, ((1,2), (3,4), (5,6), (7,8)))
-
-    def testCallArrayStructsOut(self):
-
-        obj = OC_TestArrayStruct_Out.alloc().init()
-
-        v = OC_ArrayTest.callArrayOf4StructsOut_(obj)
-        self.assertEquals(v, [ (44, 45), (46, 47), (48, 49), (50, 51) ])
-
-
-if __name__ == "__main__":
-    main()

pyobjc-core/Lib/objc/test/test_bundleFunctions.py

-import objc
-import objc.test.fnd as Foundation
-from PyObjCTools.TestSupport import *
-import os
-
-NSObject = objc.lookUpClass('NSObject')
-
-def S(*args):
-    return ''.join(args)
-
-FUNCTIONS=[
-    ( u'NSHomeDirectory', S(objc._C_ID)),
-    ( u'NSIsFreedObject', S(objc._C_NSBOOL, objc._C_ID) ),
-    ( u'NSCountFrames', S(objc._C_UINT) ),
-    ( u'NSClassFromString', S(objc._C_CLASS, objc._C_ID) ),
-]
-
-class TestBundleFunctions (TestCase):
-    def setUp(self):
-        self.bundle = Foundation.NSBundle.bundleForClass_(Foundation.NSBundle)
-
-    def testSimple(self):
-        d = {}
-        objc.loadBundleFunctions(self.bundle, d, FUNCTIONS)
-
-        self.assert_('NSIsFreedObject' in d)
-        self.assert_('NSCountFrames' in d)
-        self.assert_('NSHomeDirectory' in d)
-
-        # Don't use this API, it is unsupported and causes warnings.
-        #fn = d[u'NSIsFreedObject']
-        #obj = NSObject.alloc().init()
-        #value = fn(obj)
-        #self.assert_(not value)
-
-        fn = d[u'NSHomeDirectory']
-        value = fn()
-        self.assertEquals(value, os.path.expanduser('~'))
-
-        fn = d[u'NSClassFromString']
-        value = fn(u'NSObject')
-        self.assert_(value is NSObject)
-
-        # Need to look for a different example, NSCountFrames crashes
-        # (that is the actual function, not the dynamic wrapper)
-        #fn = d[u'NSCountFrames']
-        #import Foundation
-        #fn = Foundation.NSCountFrames
-        #value = fn()
-        #self.assert_(isistance(value, int))
-
-
-if __name__ == "__main__":
-    main()
-
-

pyobjc-core/Lib/objc/test/test_bundleVariables.py

-import objc
-import objc.test.fnd as Foundation
-from PyObjCTools.TestSupport import *
-
-class TestBundleVariables (TestCase):
-    def setUp(self):
-        self.bundle = Foundation.NSBundle.bundleForClass_(Foundation.NSBundle)
-
-    def testStrings(self):
-        d = {}
-        objc.loadBundleVariables(self.bundle, d, [
-                (u'NSAppleScriptErrorMessage', '@'),
-                (u'NSBundleDidLoadNotification', '@'),
-            ])
-
-        self.assert_(u'NSBundleDidLoadNotification' in d)
-        self.assert_(u'NSAppleScriptErrorMessage' in d)
-
-        self.assert_(isinstance(d[u'NSAppleScriptErrorMessage'], objc.pyobjc_unicode))
-        self.assert_(isinstance(d[u'NSBundleDidLoadNotification'], objc.pyobjc_unicode))
-
-    def testSimple(self):
-        d = {}
-        objc.loadBundleVariables(self.bundle, d, [
-                (u'NSDebugEnabled', objc._C_NSBOOL),
-                (u'NSFoundationVersionNumber', objc._C_DBL),
-            ])
-
-        self.assert_(u'NSDebugEnabled' in d)
-        self.assert_(u'NSFoundationVersionNumber' in d)
-
-        self.assert_(isinstance(d[u'NSFoundationVersionNumber'], float))
-        self.assert_(isinstance(d[u'NSDebugEnabled'], int))
-
-
-if __name__ == "__main__":
-    main()
-
-

pyobjc-core/Lib/objc/test/test_classandinst.py

-from PyObjCTools.TestSupport import *
-import objc
-from objc.test.testclassandinst import PyObjC_TestClassAndInstance, PyObjC_TestUnallocatable
-
-class PyObjC_TestClassAndInstanceSubclass(PyObjC_TestClassAndInstance):
-    """Simple subclass, just make sure it still works"""
-    pass
-
-
-# XXX: Huh? The next two classes have the same definition?
-class PyObjC_TestClassAndInstanceClassOverride(PyObjC_TestClassAndInstance):
-    """return YES for both"""
-    def isInstance(klass):
-        return objc.YES
-    isInstance = classmethod(isInstance)
-
-class PyObjC_TestClassAndInstanceInstanceOverride(PyObjC_TestClassAndInstance):
-    """return NO for both"""
-    def isInstance(self):
-        return objc.NO
-
-# class PyObjC_TestClassAndInstanceBothOverride(PyObjC_TestClassAndInstance):
-#     """flipped"""
-#     def isInstance__class__(self):
-#         return objc.YES
-#
-#     def isInstance__inst__(self):
-#         return objc.NO
-
-class TestClassAndInstance(TestCase):
-    def testClassAndInstanceInstanceOverrideWorkaround(self):
-        self.failIf(PyObjC_TestClassAndInstanceInstanceOverride.pyobjc_classMethods.isInstance())
-        self.failIf(PyObjC_TestClassAndInstanceInstanceOverride.alloc().init().pyobjc_instanceMethods.isInstance())
-
-    def testClassAndInstanceClassOverrideWorkaround(self):
-        self.failUnless(PyObjC_TestClassAndInstanceClassOverride.pyobjc_classMethods.isInstance())
-
-    def testClassAndInstanceSubclassWorkaround(self):
-        self.failIf(PyObjC_TestClassAndInstanceSubclass.pyobjc_classMethods.isInstance())
-        self.failUnless(PyObjC_TestClassAndInstanceSubclass.alloc().init().pyobjc_instanceMethods.isInstance())
-
-    def testClassAndInstanceWorkaround(self):
-        if PyObjC_TestClassAndInstance.pyobjc_classMethods.isInstance():
-            self.fail()
-
-        self.failIf(PyObjC_TestClassAndInstance.pyobjc_classMethods.isInstance())
-        self.failUnless(PyObjC_TestClassAndInstance.alloc().init().pyobjc_instanceMethods.isInstance())
-
-    def testClassAndInstanceClassOverride(self):
-        self.failUnless(PyObjC_TestClassAndInstanceClassOverride.isInstance())
-        self.failUnless(PyObjC_TestClassAndInstanceClassOverride.alloc().init().isInstance())
-
-    def testClassAndInstanceInstanceOverride(self):
-        # Having the next line true would be nice:
-        #self.failIf(PyObjC_TestClassAndInstanceInstanceOverride.isInstance())
-        # But we'll have to settle for this one instead:
-        self.failIf(PyObjC_TestClassAndInstanceInstanceOverride.pyobjc_classMethods.isInstance())
-        self.failIf(PyObjC_TestClassAndInstanceInstanceOverride.alloc().init().isInstance())
-
-    def testClassAndInstanceSubclass(self):
-        # Having the next line true would be nice:
-        #self.failIf(PyObjC_TestClassAndInstanceSubclass.isInstance())
-        # But we'll have to settle for this one instead:
-        self.failIf(PyObjC_TestClassAndInstanceSubclass.pyobjc_classMethods.isInstance())
-        self.failUnless(PyObjC_TestClassAndInstanceSubclass.alloc().init().isInstance())
-
-    def testClassAndInstance(self):
-
-        # Having the next line true would be nice:
-        #self.assertEquals(PyObjC_TestClassAndInstance.isInstance(), objc.NO)
-        # But we'll have to settle for this one instead:
-        self.failIf(PyObjC_TestClassAndInstance.pyobjc_classMethods.isInstance())
-        self.failUnless(PyObjC_TestClassAndInstance.alloc().init().isInstance())
-
-    def testUnallocatable(self):
-        self.assertEquals(PyObjC_TestUnallocatable.alloc(), None)
-
-if __name__ == '__main__':
-    main()

pyobjc-core/Lib/objc/test/test_clinmeth.py

-"""
-Tests for accessing methods through classes and instances
-"""
-from PyObjCTools.TestSupport import *
-from objc.test.clinmeth import *
-import objc
-
-class TestClassMethods (TestCase):
-    # Some very basic tests that check that getattr on instances doesn't
-    # return a class method and that getattr on classes prefers classmethods
-    # over instance methods (and v.v. for getattr on instances)
-
-    def testViaClass(self):
-        m = PyObjC_ClsInst1.clsmeth
-        self.assert_( isinstance(m, objc.selector) )
-        self.assert_( m.isClassMethod )
-
-        self.assertEquals(m(), 4)
-
-    def testViaInstance(self):
-        o = PyObjC_ClsInst1.alloc().init()
-        self.assertRaises(AttributeError, getattr, o, "clsmeth")
-
-    def testClassAndInstanceViaClass(self):
-        m = PyObjC_ClsInst1.both
-        self.assert_( isinstance(m, objc.selector) )
-        self.assert_( m.__metadata__()['classmethod'] )
-
-        self.assertEquals(m(), 3)
-
-    def testClassAndInstanceViaInstance(self):
-        o = PyObjC_ClsInst1.alloc().init()
-        m = o.both
-        self.assert_( isinstance(m, objc.selector) )
-        self.assert_( not m.isClassMethod )
-
-        self.assertEquals(m(), 2)
-
-
-class TestInstanceMethods (TestCase):
-    # Check that instance methods can be accessed through the instance, and 
-    # also through the class when no class method of the same name is 
-    # available.
-
-    def testViaClass(self):
-        m = PyObjC_ClsInst1.instance
-        self.assert_( isinstance(m, objc.selector) )
-        self.assert_( not m.isClassMethod )
-
-        self.assertRaises(TypeError, m)
-
-    def testViaInstance(self):
-        o = PyObjC_ClsInst1.alloc().init()
-        m = o.instance
-
-        self.assert_( isinstance(m, objc.selector) )
-        self.assert_( not m.isClassMethod )
-
-        self.assertEquals(m(), 1)
-
-class TestSuper (TestCase):
-    # Tests that check if super() behaves as expected (which is the most likely
-    # reason for failure).
-
-    def testClassMethod(self):
-        cls = PyObjC_ClsInst2
-
-        self.assertEquals(cls.clsmeth(), 40)
-        self.assertEquals(objc.super(cls, cls).clsmeth(), 4)
-
-    def testInstanceMethod(self):
-        o = PyObjC_ClsInst2.alloc().init()
-
-        self.assertEquals(o.instance(), 10)
-        self.assertEquals(super(PyObjC_ClsInst2, o).instance(), 1)
-
-    def testBoth(self):
-        o = PyObjC_ClsInst2.alloc().init()
-
-        self.assertEquals(o.both(), 20)
-        self.assertEquals(objc.super(PyObjC_ClsInst2, o).both(), 2)
-
-        cls = PyObjC_ClsInst2
-
-        self.assertEquals(cls.both(), 30)
-        self.assertEquals(objc.super(cls, cls).both(), 3)
-
-
-if __name__ == "__main__":
-    main()
-

pyobjc-core/Lib/objc/test/test_conversion.py

-"""
-Some basic tests for converting values to and from Objective-C
-
-TODO: This only tests C values at the moment.
-"""
-from PyObjCTools.TestSupport import *
-from objc.test.testbndl import pyObjCPy, carrayMaker
-from objc.test.testbndl import UCHAR_MAX
-from objc.test.testbndl import CHAR_MAX, CHAR_MIN
-from objc.test.testbndl import SCHAR_MAX, SCHAR_MIN
-from objc.test.testbndl import USHRT_MAX, SHRT_MAX, SHRT_MIN
-from objc.test.testbndl import UINT_MAX, INT_MAX, INT_MIN
-from objc.test.testbndl import ULONG_MAX, LONG_MAX, LONG_MIN
-from objc.test.testbndl import ULLONG_MAX, LLONG_MAX, LLONG_MIN
-from objc.test.testbndl import DBL_MAX, DBL_MIN, DBL_EPSILON
-from objc.test.testbndl import FLT_MAX, FLT_MIN, FLT_EPSILON
-import objc
-import array, sys
-
-
-class TestNumbers (TestCase):
-    """
-    Test of conversion of numbers, especially boundary cases
-    """
-
-    def test_unsigned_char(self):
-        self.assertEquals(0, pyObjCPy(objc._C_UCHR, 0))
-        self.assertEquals(0, pyObjCPy(objc._C_UCHR, '\0'))
-        self.assertEquals(0, pyObjCPy(objc._C_UCHR, long(0)))
-        self.assertEquals(0, pyObjCPy(objc._C_UCHR, float(0)))
-
-        self.assertEquals(UCHAR_MAX, pyObjCPy(objc._C_UCHR, UCHAR_MAX))
-        self.assertEquals(UCHAR_MAX, pyObjCPy(objc._C_UCHR, chr(UCHAR_MAX)))
-        self.assertEquals(UCHAR_MAX, pyObjCPy(objc._C_UCHR, long(UCHAR_MAX)))
-        self.assertEquals(UCHAR_MAX, pyObjCPy(objc._C_UCHR, float(UCHAR_MAX)))
-
-        self.assertRaises(ValueError, pyObjCPy, objc._C_UCHR, SCHAR_MIN)
-        self.assertRaises(ValueError, pyObjCPy, objc._C_UCHR, SCHAR_MIN - 1)
-
-    def test_char(self):
-        self.assertEquals(0, pyObjCPy(objc._C_CHR, 0))
-        self.assertEquals(0, pyObjCPy(objc._C_CHR, chr(0)))
-        self.assertEquals(0, pyObjCPy(objc._C_CHR, long(0)))
-
-        self.assertEquals(CHAR_MAX, pyObjCPy(objc._C_CHR, CHAR_MAX))
-        self.assertEquals(CHAR_MAX, pyObjCPy(objc._C_CHR, chr(CHAR_MAX)))
-        self.assertEquals(CHAR_MIN, pyObjCPy(objc._C_CHR, CHAR_MIN))
-        self.assertEquals(CHAR_MAX, pyObjCPy(objc._C_CHR, long(CHAR_MAX)))
-        self.assertEquals(CHAR_MIN, pyObjCPy(objc._C_CHR, long(CHAR_MIN)))
-        self.assertEquals(CHAR_MAX, pyObjCPy(objc._C_CHR, float(CHAR_MAX)))
-        self.assertEquals(CHAR_MIN, pyObjCPy(objc._C_CHR, float(CHAR_MIN)))
-
-        # XXX: Is the right, chr(-1) raises an exception, and is not
-        # equivalent to '\xff'. Should (char)-1 be converted to '\xff'/255 ?
-        self.assertEquals(-1, pyObjCPy(objc._C_CHR, '\xff'))
-
-        self.assertRaises(ValueError, pyObjCPy, objc._C_CHR, CHAR_MAX + 1)
-        self.assertRaises(ValueError, pyObjCPy, objc._C_CHR, CHAR_MIN - 1)
-
-    def test_unsigned_short(self):
-        self.assertEquals(0, pyObjCPy(objc._C_USHT, 0))
-        self.assertEquals(USHRT_MAX, pyObjCPy(objc._C_USHT, USHRT_MAX))
-        self.assertEquals(0, pyObjCPy(objc._C_USHT, long(0)))
-        self.assertEquals(USHRT_MAX, pyObjCPy(objc._C_USHT, long(USHRT_MAX)))
-        self.assertEquals(0, pyObjCPy(objc._C_USHT, float(0)))
-        self.assertEquals(USHRT_MAX, pyObjCPy(objc._C_USHT, float(USHRT_MAX)))
-
-        self.assertRaises(ValueError, pyObjCPy, objc._C_USHT, SHRT_MIN)
-        self.assertRaises(ValueError, pyObjCPy, objc._C_USHT, SHRT_MIN - 1)
-
-        self.assertRaises(ValueError, pyObjCPy, objc._C_USHT, "1")
-
-    def test_short(self):
-        self.assertEquals(0, pyObjCPy(objc._C_SHT, 0))
-        self.assertEquals(SHRT_MAX, pyObjCPy(objc._C_SHT, SHRT_MAX))
-        self.assertEquals(SHRT_MIN, pyObjCPy(objc._C_SHT, SHRT_MIN))
-        self.assertEquals(0, pyObjCPy(objc._C_SHT, long(0)))
-        self.assertEquals(SHRT_MAX, pyObjCPy(objc._C_SHT, long(SHRT_MAX)))
-        self.assertEquals(SHRT_MIN, pyObjCPy(objc._C_SHT, long(SHRT_MIN)))
-        self.assertEquals(0, pyObjCPy(objc._C_SHT, float(0)))
-        self.assertEquals(SHRT_MAX, pyObjCPy(objc._C_SHT, float(SHRT_MAX)))
-        self.assertEquals(SHRT_MIN, pyObjCPy(objc._C_SHT, float(SHRT_MIN)))
-
-        self.assertRaises(ValueError, pyObjCPy, objc._C_SHT, SHRT_MAX + 1)
-        self.assertRaises(ValueError, pyObjCPy, objc._C_SHT, SHRT_MIN - 1)
-
-        self.assertRaises(ValueError, pyObjCPy, objc._C_SHT, "1")
-
-    def test_unsigned_int(self):
-        self.assertEquals(0, pyObjCPy(objc._C_UINT, 0))
-        self.assertEquals(UINT_MAX, pyObjCPy(objc._C_UINT, UINT_MAX))
-        self.assertEquals(0, pyObjCPy(objc._C_UINT, long(0)))
-        self.assertEquals(UINT_MAX, pyObjCPy(objc._C_UINT, long(UINT_MAX)))
-        self.assertEquals(0, pyObjCPy(objc._C_UINT, float(0)))
-        self.assertEquals(UINT_MAX, pyObjCPy(objc._C_UINT, float(UINT_MAX)))
-
-        self.assertRaises(ValueError, pyObjCPy, objc._C_UINT, INT_MIN)
-        self.assertRaises(ValueError, pyObjCPy, objc._C_UINT, INT_MIN - 1)
-
-        self.assertRaises(ValueError, pyObjCPy, objc._C_UINT, "1")
-
-    def test_int(self):
-        self.assertEquals(0, pyObjCPy(objc._C_INT, 0))
-        self.assertEquals(INT_MAX, pyObjCPy(objc._C_INT, INT_MAX))
-        self.assertEquals(INT_MIN, pyObjCPy(objc._C_INT, INT_MIN))
-        self.assertEquals(0, pyObjCPy(objc._C_INT, long(0)))
-        self.assertEquals(INT_MAX, pyObjCPy(objc._C_INT, long(INT_MAX)))
-        self.assertEquals(INT_MIN, pyObjCPy(objc._C_INT, long(INT_MIN)))
-        self.assertEquals(0, pyObjCPy(objc._C_INT, float(0)))
-        self.assertEquals(INT_MAX, pyObjCPy(objc._C_INT, float(INT_MAX)))
-        self.assertEquals(INT_MIN, pyObjCPy(objc._C_INT, float(INT_MIN)))
-
-        self.assertRaises(ValueError, pyObjCPy, objc._C_INT, INT_MAX + 1)
-        self.assertRaises(ValueError, pyObjCPy, objc._C_INT, INT_MIN - 1)
-
-        # Check implicit conversion
-        self.assertRaises(ValueError, pyObjCPy, objc._C_INT, "1")
-
-    def test_unsigned_long(self):
-        self.assertEquals(0, pyObjCPy(objc._C_ULNG, 0))
-        self.assertEquals(ULONG_MAX, pyObjCPy(objc._C_ULNG, ULONG_MAX))
-        self.assertEquals(0, pyObjCPy(objc._C_ULNG, long(0)))
-        self.assertEquals(ULONG_MAX, pyObjCPy(objc._C_ULNG, long(ULONG_MAX)))
-        self.assertEquals(0, pyObjCPy(objc._C_ULNG, float(0)))
-
-        if sys.maxint < 2 ** 32:
-            self.assertEquals(ULONG_MAX, pyObjCPy(objc._C_ULNG, float(ULONG_MAX)))
-            self.assertRaises(ValueError, pyObjCPy, objc._C_ULNG, LONG_MIN)
-            self.assertRaises(ValueError, pyObjCPy, objc._C_ULNG, LONG_MIN - 1)
-
-        self.assertRaises(ValueError, pyObjCPy, objc._C_ULNG, "1")
-
-    def test_long(self):
-        self.assertEquals(0, pyObjCPy(objc._C_LNG, 0))
-        self.assertEquals(LONG_MAX, pyObjCPy(objc._C_LNG, LONG_MAX))
-        self.assertEquals(LONG_MIN, pyObjCPy(objc._C_LNG, LONG_MIN))
-        self.assertEquals(0, pyObjCPy(objc._C_LNG, long(0)))
-        self.assertEquals(LONG_MAX, pyObjCPy(objc._C_LNG, long(LONG_MAX)))
-        self.assertEquals(LONG_MIN, pyObjCPy(objc._C_LNG, long(LONG_MIN)))
-        self.assertEquals(0, pyObjCPy(objc._C_LNG, float(0)))
-        if sys.maxint < 2 ** 32:
-            self.assertEquals(LONG_MAX, pyObjCPy(objc._C_LNG, float(LONG_MAX)))
-            self.assertEquals(LONG_MIN, pyObjCPy(objc._C_LNG, float(LONG_MIN)))
-
-        self.assertRaises(ValueError, pyObjCPy, objc._C_LNG, LONG_MAX + 1)
-        self.assertRaises(ValueError, pyObjCPy, objc._C_LNG, LONG_MIN - 1)
-
-        self.assertRaises(ValueError, pyObjCPy, objc._C_LNG, "1")
-
-    def test_unsigned_long_long(self):
-        self.assertEquals(0, pyObjCPy(objc._C_ULNG_LNG, 0))
-        self.assertEquals(ULLONG_MAX, pyObjCPy(objc._C_ULNG_LNG, ULLONG_MAX))
-        self.assertEquals(0, pyObjCPy(objc._C_ULNG_LNG, long(0)))
-        self.assertEquals(ULLONG_MAX, pyObjCPy(objc._C_ULNG_LNG, long(ULLONG_MAX)))
-        self.assertEquals(0, pyObjCPy(objc._C_ULNG_LNG, float(0)))
-
-        self.assertRaises(ValueError, pyObjCPy, objc._C_ULNG_LNG, LLONG_MIN)
-        self.assertRaises(ValueError, pyObjCPy, objc._C_ULNG_LNG, LLONG_MIN - 1)
-
-        self.assertRaises(ValueError, pyObjCPy, objc._C_ULNG_LNG, "1")
-
-    def test_long_long(self):
-        self.assertEquals(0, pyObjCPy(objc._C_LNG_LNG, 0))
-
-        if sys.maxint < 2 ** 32:
-            self.assertEquals(LONG_MAX, pyObjCPy(objc._C_LNG_LNG, float(LONG_MAX)))
-        self.assertEquals(LLONG_MAX, pyObjCPy(objc._C_LNG_LNG, LLONG_MAX))
-        self.assertEquals(LLONG_MIN, pyObjCPy(objc._C_LNG_LNG, LLONG_MIN))
-
-        self.assertRaises(ValueError, pyObjCPy, objc._C_LNG_LNG, LLONG_MAX + 1)
-        self.assertRaises(ValueError, pyObjCPy, objc._C_LNG_LNG, LLONG_MIN - 1)
-
-        self.assertRaises(ValueError, pyObjCPy, objc._C_LNG_LNG, "1")
-
-    def test_double(self):
-        self.assertEquals(0, pyObjCPy(objc._C_DBL, 0))
-        self.assertEquals(float(INT_MAX), pyObjCPy(objc._C_DBL, INT_MAX))
-        self.assertEquals(DBL_MAX, pyObjCPy(objc._C_DBL, DBL_MAX))
-        self.assertEquals(DBL_MIN, pyObjCPy(objc._C_DBL, DBL_MIN))
-        self.assertEquals(-DBL_MAX, pyObjCPy(objc._C_DBL, -DBL_MAX))
-        self.assertEquals(-DBL_MIN, pyObjCPy(objc._C_DBL, -DBL_MIN))
-        self.assertEquals(DBL_EPSILON, pyObjCPy(objc._C_DBL, DBL_EPSILON))
-        self.assertEquals(-DBL_EPSILON, pyObjCPy(objc._C_DBL, -DBL_EPSILON))
-
-        self.assertRaises(ValueError, pyObjCPy, objc._C_DBL, 1L << 10000)
-
-        self.assertRaises(ValueError, pyObjCPy, objc._C_DBL, "1")
-
-    def test_float(self):
-        self.assertEquals(0, pyObjCPy(objc._C_FLT, 0))
-        self.assertEquals(float(SHRT_MAX), pyObjCPy(objc._C_FLT, SHRT_MAX))
-        self.assertEquals(FLT_MAX, pyObjCPy(objc._C_FLT, FLT_MAX))
-        self.assertEquals(FLT_MIN, pyObjCPy(objc._C_FLT, FLT_MIN))
-        self.assertEquals(-FLT_MAX, pyObjCPy(objc._C_FLT, -FLT_MAX))
-        self.assertEquals(-FLT_MIN, pyObjCPy(objc._C_FLT, -FLT_MIN))
-        self.assertEquals(FLT_EPSILON, pyObjCPy(objc._C_FLT, FLT_EPSILON))
-        self.assertEquals(-FLT_EPSILON, pyObjCPy(objc._C_FLT, -FLT_EPSILON))
-
-        # Just in cause we do something stupid and convert to double instead
-        # of float
-        self.assertNotEquals(DBL_MAX, pyObjCPy(objc._C_FLT, DBL_MAX))
-
-        self.assertRaises(ValueError, pyObjCPy, objc._C_FLT, 1L << 10000)
-
-        self.assertRaises(ValueError, pyObjCPy, objc._C_FLT, "1")
-
-
-class TestStruct (TestCase):
-    """
-    Structs are usually represented as tuples, but any sequence type is
-    accepted as input, as long as it has the right number of elements
-    """
-
-    def testSimple(self):
-        # struct Foo {
-        #    int;
-        #    int;
-        # };
-        signature = "{Foo=ii}"
-
-        inval = (1, 2)
-
-        self.assertEquals(inval, pyObjCPy(signature, inval))
-        self.assertEquals(inval, pyObjCPy(signature, list(inval)))
-        self.assertEquals(inval, pyObjCPy(signature, iter(inval)))
-        self.assertEquals(inval, pyObjCPy(signature, iter(list(inval))))
-
-    def testHoles(self):
-        # This struct usually contains holes
-        #
-        # struct Foo {
-        #   short;
-        #   int;
-        #   short;
-        #   double;
-        #   short;
-        # };
-        signature = "{Foo=sisds}"
-
-        inval = (1, 2, 3, 4.0, 5)
-
-        self.assertEquals(inval, pyObjCPy(signature, inval))
-        self.assertEquals(inval, pyObjCPy(signature, list(inval)))
-        self.assertEquals(inval, pyObjCPy(signature, iter(inval)))
-        self.assertEquals(inval, pyObjCPy(signature, iter(list(inval))))
-
-class TestArray (TestCase):
-    def test_simple(self):
-        signature = '[10i]'
-        value = tuple(range(10))
-
-        self.assertEquals(value, tuple(pyObjCPy(signature, value)))
-        self.assertEquals(value, tuple(pyObjCPy(signature, list(value))))
-        self.assertEquals(value, tuple(pyObjCPy(signature, iter(value))))
-        self.assertEquals(value, tuple(pyObjCPy(signature, iter(list(value)))))
-
-        self.assertRaises(ValueError, pyObjCPy, signature, value + value[:1])
-        self.assertRaises(ValueError, pyObjCPy, signature, value[:9])
-        self.assertRaises(ValueError, pyObjCPy, signature, iter(value + value[:1]))
-        self.assertRaises(ValueError, pyObjCPy, signature, iter(value[:9]))
-        self.assertRaises(TypeError, pyObjCPy, signature, None)
-
-class TestCArray (TestCase):
-    # Tests for the PyObjC_PythonToCArray (C-)function, this function is
-    # used to build variable-length C Arrays from Python objects.
-
-    # TODO: "{_NSPoint=ff}", "{_NSRect={_NSPoint=ff}{_NSSize=ff}}"
-    #       "[4i]" "[4[4i]]" "[2{foo=ii}]" "{foo=[4i]}"
-    #       "{_Foo=fi}" (fail with array.array) + version with [{foo=if}]
-    #       - other simple types
-    def testShortTuple(self):
-        arr = (1,2,3,4,5)
-
-        res = carrayMaker(objc._C_SHT, arr, None)
-        self.assertEquals(res, arr)
-
-        res = carrayMaker(objc._C_SHT, arr, 2)
-        self.assertEquals(res, arr[:2])
-
-        self.assertRaises(ValueError, carrayMaker, objc._C_SHT, arr, 7)
-        self.assertRaises(ValueError, carrayMaker, objc._C_SHT, ["a", "b"], 1)
-
-    def testShortArray(self):
-        arr = array.array('h', [1,2,3,4,5])
-        arr2 = array.array('f', [1,2,3,4,5])
-
-        res = carrayMaker(objc._C_SHT, arr, None)
-        self.assertEquals(res, tuple(arr))
-
-        res = carrayMaker(objc._C_SHT, arr, 2)
-        self.assertEquals(res, tuple(arr)[:2])
-
-        self.assertRaises(ValueError, carrayMaker, objc._C_SHT, arr, 7)
-        self.assertRaises(ValueError, carrayMaker, objc._C_SHT, arr2, None)
-
-    def testIntTuple(self):
-        arr = (1,2,3,4,5)
-
-        res = carrayMaker(objc._C_INT, arr, None)
-        self.assertEquals(res, arr)
-
-        res = carrayMaker(objc._C_INT, arr, 2)
-        self.assertEquals(res, arr[:2])
-
-        self.assertRaises(ValueError, carrayMaker, objc._C_INT, arr, 7)
-        self.assertRaises(ValueError, carrayMaker, objc._C_INT, ["a", "b"], 1)
-
-    def testIntArray(self):
-        arr = array.array('i', [1,2,3,4,5])
-        arr2 = array.array('f', [1,2,3,4,5])
-        arr3 = array.array('h', [1,2,3,4,5])
-
-        res = carrayMaker(objc._C_INT, arr, None)
-        self.assertEquals(res, tuple(arr))
-
-        res = carrayMaker(objc._C_INT, arr, 2)
-        self.assertEquals(res, tuple(arr)[:2])
-
-        self.assertRaises(ValueError, carrayMaker, objc._C_INT, arr, 7)
-        self.assertRaises(ValueError, carrayMaker, objc._C_INT, arr2, None)
-        self.assertRaises(ValueError, carrayMaker, objc._C_INT, arr3, None)
-
-    def testFloatTuple(self):
-        arr = (1,2,3,4,5)
-
-        res = carrayMaker(objc._C_FLT, arr, None)
-        self.assertEquals(res, arr)
-
-        res = carrayMaker(objc._C_FLT, arr, 2)
-        self.assertEquals(res, arr[:2])
-
-        self.assertRaises(ValueError, carrayMaker, objc._C_INT, arr, 7)
-        self.assertRaises(ValueError, carrayMaker, objc._C_INT, ["a", "b"], 1)
-
-    def testFloatArray(self):
-        arr = array.array('f', [1.5,2.5,3.5,4.5,5.5])
-        arr2 = array.array('i', [1,2,3,4,5])
-
-        res = carrayMaker(objc._C_FLT, arr, None)
-        self.assertEquals(res, tuple(arr))
-
-        res = carrayMaker(objc._C_FLT, arr, 2)
-        self.assertEquals(res, tuple(arr)[:2])
-
-        self.assertRaises(ValueError, carrayMaker, objc._C_FLT, arr, 7)
-        self.assertRaises(ValueError, carrayMaker, objc._C_FLT, arr2, None)
-
-    def testPointTuple(self):
-        arr = ((1.0, 1.5), (2.0, 2.5), (3.0, 3.5), (4.0, 4.5), (5.0, 5.5))
-        arr2 = (1.5,2.5,3.5,4.5,5.5)
-
-        res = carrayMaker('{Point=ff}', arr, None)
-        self.assertEquals(res, arr)
-
-        res = carrayMaker('{Point=ff}', arr, 2)
-        self.assertEquals(res, arr[:2])
-
-        self.assertRaises(ValueError, carrayMaker, '{Point=ff}', arr, 7)
-        self.assertRaises(ValueError, carrayMaker, '{Point=ff}', ["a", "b"], 1)
-        self.assertRaises(TypeError, carrayMaker, '{Point=ff}', arr2, None)
-
-    def testPointArray(self):
-        arr = array.array('f', [
-            1.0, 1.5,
-            2.0, 2.5,
-            3.0, 3.5,
-            4.0, 4.5,
-            5.0, 5.5])
-        lst = ((1.0, 1.5), (2.0, 2.5), (3.0, 3.5), (4.0, 4.5), (5.0, 5.5))
-
-        arr2 = array.array('i', [
-            1, 1,
-            2, 2,
-            3, 3,
-            4, 4,
-            5, 5])
-
-        res = carrayMaker('{Point=ff}', arr, None)
-        self.assertEquals(res, lst)
-
-        res = carrayMaker('{Point=ff}', arr, 2)
-        self.assertEquals(res, lst[:2])
-
-        self.assertRaises(ValueError, carrayMaker, '{Point=ff}', arr2, None)
-
-    def testRectArray(self):
-        arr = array.array('f', [
-            1.0, 1.5, -1.0, -1.5,
-            2.0, 2.5, -2.0, -2.5,
-            3.0, 3.5, -3.0, -3.5,
-            4.0, 4.5, -4.0, -4.5,
-            5.0, 5.5, -5.0, -5.5])
-        lst = (
-                ((1.0, 1.5),  (-1.0, -1.5)),
-                ((2.0, 2.5),  (-2.0, -2.5)),
-                ((3.0, 3.5),  (-3.0, -3.5)),
-                ((4.0, 4.5),  (-4.0, -4.5)),
-                ((5.0, 5.5),  (-5.0, -5.5)),
-            )
-
-        arr2 = array.array('i', [
-            1, 1, 1, 1,
-            2, 2, 2, 2,
-            3, 3, 3, 3,
-            4, 4, 4, 4,
-            5, 5, 5, 5])
-
-        res = carrayMaker('{Rect={P=ff}{S=ff}}', arr, None)
-        self.assertEquals(res, lst)
-
-        res = carrayMaker('{Rect={P=ff}{S=ff}}', arr, 2)
-        self.assertEquals(res, lst[:2])
-
-        res = carrayMaker('{Rect=[2f][2f]}', arr, None)
-        self.assertEquals(res, lst)
-
-        res = carrayMaker('[2[2f]]}', arr, None)
-        self.assertEquals(res, lst)
-
-        self.assertRaises(ValueError, carrayMaker, '{Rect={P=ff}{S=ff}}', arr2, None)
-
-    def testMixedArray(self):
-        arr = array.array('f', [
-            1.0, 1.5, -1.0, -1.5,
-            2.0, 2.5, -2.0, -2.5,
-            3.0, 3.5, -3.0, -3.5,
-            4.0, 4.5, -4.0, -4.5,
-            5.0, 5.5, -5.0, -5.5])
-
-        self.assertRaises(ValueError, carrayMaker, '{M={P=ff}{S=ii}}', arr, 4)
-        self.assertRaises(ValueError, carrayMaker, '{M=if{S=ii}}', arr, None)
-        self.assertRaises(ValueError, carrayMaker, '{M=fi{S=ff}}', arr, None)
-
-
-
-class PyOCTestTypeStr(TestCase):
-    #
-    # Check that typestrings have the expected values.
-    # We currently depend on these values in this file as wel as in the
-    # modules that set method signatures to 'better' values.
-    #
-    def testAll(self):
-        if hasattr(objc, '_C_BOOL'):
-            self.assertEquals(objc._C_BOOL, "B")
-        self.assertEquals(objc._C_ID, "@")
-        self.assertEquals(objc._C_CLASS, "#")
-        self.assertEquals(objc._C_SEL, ":")
-        self.assertEquals(objc._C_CHR, "c")
-        self.assertEquals(objc._C_UCHR, "C")
-        self.assertEquals(objc._C_SHT, "s")
-        self.assertEquals(objc._C_USHT, "S")
-        self.assertEquals(objc._C_INT, "i")
-        self.assertEquals(objc._C_UINT, "I")
-        self.assertEquals(objc._C_LNG, "l")
-        self.assertEquals(objc._C_ULNG, "L")
-        self.assertEquals(objc._C_LNG_LNG, "q")
-        self.assertEquals(objc._C_ULNG_LNG, "Q")
-        self.assertEquals(objc._C_FLT, "f")
-        self.assertEquals(objc._C_DBL, "d")
-        self.assertEquals(objc._C_VOID, "v")
-        self.assertEquals(objc._C_CHARPTR, "*")
-        self.assertEquals(objc._C_PTR, "^")
-        self.assertEquals(objc._C_UNDEF, "?")
-        self.assertEquals(objc._C_ARY_B, "[")
-        self.assertEquals(objc._C_ARY_E, "]")
-        self.assertEquals(objc._C_UNION_B, "(")
-        self.assertEquals(objc._C_UNION_E, ")")
-        self.assertEquals(objc._C_STRUCT_B, "{")
-        self.assertEquals(objc._C_STRUCT_E, "}")
-        self.assertEquals(objc._C_IN, "n")
-        self.assertEquals(objc._C_OUT, "o")
-        self.assertEquals(objc._C_INOUT, "N")
-
-if __name__ == "__main__":
-    main()

pyobjc-core/Lib/objc/test/test_copying.py

-from PyObjCTools.TestSupport import *
-import objc
-
-NSObject = objc.lookUpClass("NSObject")
-NSAutoreleasePool = objc.lookUpClass("NSAutoreleasePool")
-from objc.test.copying import OC_CopyHelper, OC_CopyBase
-
-def funcattr(**kwds):
-    def annotate(func):
-        for k, v in kwds.iteritems():
-            setattr(func, k, v)
-        return func
-    return annotate
-
-class OC_TestCopy1 (NSObject):
-    def init(self):
-        self = super(OC_TestCopy1, self).init()
-        if self is not None:
-            self.x = 1
-            self.y = 2
-        return self
-
-    def modify(self):
-        self.x = 42
-        self.y = 24
-        self.z = 0
-
-    @funcattr(occlass="OC_TestCopy1")
-    def copyWithZone_(self, zone):
-        other = OC_TestCopy1.allocWithZone_(zone).init()
-        other.x = self.x
-        other.y = self.y
-        return other
-    # Argh, copyWithZone_ is a classmethod by default unless the
-    # superclass implements  -copyWithZone:
-    copyWithZone_ = objc.selector(copyWithZone_, 
-            signature=NSObject.copyWithZone_.signature, 
-            isClassMethod=False)
-
-class OC_TestCopy2 (OC_CopyBase):
-    def init(self):
-        self = super(OC_TestCopy2, self).initWithInt_(10)
-        if self is not None:
-            self.x = 1
-            self.y = 2
-        return self
-
-    def modify(self):
-        self.setIntVal_(40)
-        self.x = 42
-        self.y = 24
-        self.z = 0
-
-class OC_TestCopy3 (OC_CopyBase):
-    __slots__ = 'x y'.split()