Bob Ippolito avatar Bob Ippolito committed 3d7b365

skip formal protocol tests on Jaguar because it crashes if you define
a protocol in an MH_BUNDLE

Comments (0)

Files changed (3)

Lib/objc/test/test_protocol.py

 import objc
 import warnings
 
-from objc.test.protocol import OC_TestProtocol
-
 # Most useful systems will at least have 'NSObject'.
 NSObject = objc.lookUpClass('NSObject')
 
+# XXX : This is a really dumb way to detect < 10.3
+if not NSObject.instancesRespondToSelector_('setValue:forKey:'):
+    # Defining protocols in an MH_BUNDLE makes < 10.3 explode
+    OC_TestProtocol = None
+else:
+    from objc.test.protocol import OC_TestProtocol
+
 MyProto = objc.informal_protocol("MyProto", (
     objc.selector(None, selector="testMethod", signature="I@:", isRequired=1),
     objc.selector(None, selector="testMethod2:", signature="v@:i", isRequired=0)
     objc.selector(None, selector="aClassOne:", signature="@@:i", isClassMethod=1),
 ])
 
+if OC_TestProtocol is not None:
+
+    class TestFormalOCProtocols(unittest.TestCase):
+        
+        def testImplementFormalProtocol(self):
+
+            class MyClassNotImplementingProtocol(NSObject):
+                pass
+
+            self.assert_(not MyClassNotImplementingProtocol.pyobjc_classMethods.conformsToProtocol_(OC_TestProtocol))
+
+            try:
+                class MyClassNotAlsoImplementingProtocol(NSObject, OC_TestProtocol):
+                    def method1(self): pass
+
+                self.fail()
+            except TypeError:
+                pass
+
+            class MyClassImplementingProtocol(NSObject, OC_TestProtocol):
+                def method1(self): pass
+                def method2_(self, a): pass
+
+            self.assert_(MyClassImplementingProtocol.pyobjc_classMethods.conformsToProtocol_(OC_TestProtocol))
+
+
+
+            # The PyObjC implementation of formal protocols is slightly looser
+            # than Objective-C itself: you can inherit part of the protocol
+            # from the superclass.
+            # XXX: not really: you won't inherit the right signatures by default
+
+            class MyClassImplementingHalfOfProtocol(NSObject):
+                    def method1(self): pass
+                    method1 = objc.selector(method1, signature='i@:')
+
+            self.assert_(not MyClassImplementingHalfOfProtocol.pyobjc_classMethods.conformsToProtocol_(OC_TestProtocol))
+
+            class MyClassImplementingAllOfProtocol(MyClassImplementingHalfOfProtocol, OC_TestProtocol):
+                    def method2_(self, v): pass
+
+            self.assert_(MyClassImplementingAllOfProtocol.pyobjc_classMethods.conformsToProtocol_(OC_TestProtocol))
+
+
+
+
 class TestFormalProtocols (unittest.TestCase):
     # Implement unittests for formal protocols here.
     #
 
-    def testImplementFormalProtocol(self):
-
-        class MyClassNotImplementingProtocol(NSObject):
-            pass
-
-        self.assert_(not MyClassNotImplementingProtocol.pyobjc_classMethods.conformsToProtocol_(OC_TestProtocol))
-
-        try:
-            class MyClassNotAlsoImplementingProtocol(NSObject, OC_TestProtocol):
-                def method1(self): pass
-
-            self.fail()
-        except TypeError:
-            pass
-
-        class MyClassImplementingProtocol(NSObject, OC_TestProtocol):
-            def method1(self): pass
-            def method2_(self, a): pass
-
-        self.assert_(MyClassImplementingProtocol.pyobjc_classMethods.conformsToProtocol_(OC_TestProtocol))
-
-
-
-        # The PyObjC implementation of formal protocols is slightly looser
-        # than Objective-C itself: you can inherit part of the protocol
-        # from the superclass.
-        # XXX: not really: you won't inherit the right signatures by default
-
-        class MyClassImplementingHalfOfProtocol(NSObject):
-                def method1(self): pass
-                method1 = objc.selector(method1, signature='i@:')
-
-        self.assert_(not MyClassImplementingHalfOfProtocol.pyobjc_classMethods.conformsToProtocol_(OC_TestProtocol))
-
-        class MyClassImplementingAllOfProtocol(MyClassImplementingHalfOfProtocol, OC_TestProtocol):
-                def method2_(self, v): pass
-
-        self.assert_(MyClassImplementingAllOfProtocol.pyobjc_classMethods.conformsToProtocol_(OC_TestProtocol))
-
-
     def testImplementAnotherObject(self):
         anObject = NSObject.alloc().init()
 
 <p>An overview of the relevant changes in new, and older, releases.</p>
 <h2><a name="version-1-3-5-2005-05">Version 1.3.5 (2005-05-??)</a></h2>
 <ul>
-<li>Importing objc now ensure that Foundation is multi-threaded, previously
+<li>Importing objc now ensures that Foundation is multi-threaded, previously
 it only ensured that Python was.</li>
 <li>New <code><span>objc.RegisterCFSignature</span></code> used to register <code><span>CFTypeRef</span></code>-like
 signatures with the runtime.</li>
 Version 1.3.5 (2005-05-??)
 --------------------------
 
-- Importing objc now ensure that Foundation is multi-threaded, previously
+- Importing objc now ensures that Foundation is multi-threaded, previously
   it only ensured that Python was.
 
 - New ``objc.RegisterCFSignature`` used to register ``CFTypeRef``-like
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.