[PyObjC-svn] r2124 - in trunk/pyobjc/pyobjc-core/Lib: PyObjCTools objc

[email protected]
Newsgroups gmane.comp.python.pyobjc.cvs
Message-ID <[email protected]>
Author: ronaldoussoren
Date: Sat Mar 28 12:12:38 2009
New Revision: 2124

Log:
Improve testsupport, fix issue in _convenience API implementation.


Modified:
   trunk/pyobjc/pyobjc-core/Lib/PyObjCTools/TestSupport.py
   trunk/pyobjc/pyobjc-core/Lib/objc/_convenience.py

Modified: trunk/pyobjc/pyobjc-core/Lib/PyObjCTools/TestSupport.py
==============================================================================
--- trunk/pyobjc/pyobjc-core/Lib/PyObjCTools/TestSupport.py	(original)
+++ trunk/pyobjc/pyobjc-core/Lib/PyObjCTools/TestSupport.py	Sat Mar 28 12:12:38 2009
@@ -137,6 +137,11 @@
         if value is None:
             sel.fail(message, "%r is not %r"%(value, test))
 
+    def failUnlessResultIsNullTerminated(self, method, message = None):
+        info = method.__metadata__()
+        if not info['retval'].get('c_array_delimited_by_null'):
+            self.fail(message or "argument %d of %r is not a nul-terminated array"%(argno, method))
+
     def failUnlessArgIsNullTerminated(self, method, argno, message = None):
         if isinstance(method, objc.selector):
             offset = 2
@@ -146,6 +151,24 @@
         if not info['arguments'][argno+offset].get('c_array_delimited_by_null'):
             self.fail(message or "argument %d of %r is not a nul-terminated array"%(argno, method))
 
+    def failUnlessArgIsVariableSize(self, method, argno, message = None):
+        if isinstance(method, objc.selector):
+            offset = 2
+        else:
+            offset = 0
+        info = method.__metadata__()
+        if not info['arguments'][argno+offset].get('c_array_of_variable_length'):
+            self.fail(message or "argument %d of %r is not a variable sized array"%(argno, method))
+
+    def failUnlessArgSizeInResult(self, method, argno, message = None):
+        if isinstance(method, objc.selector):
+            offset = 2
+        else:
+            offset = 0
+        info = method.__metadata__()
+        if not info['arguments'][argno+offset].get('c_array_length_in_result'):
+            self.fail(message or "argument %d of %r does not have size in result"%(argno, method))
+
     def failUnlessArgIsPrintf(self, method, argno, message = None):
         if isinstance(method, objc.selector):
             offset = 2
@@ -300,6 +323,17 @@
             self.fail(message or "arg %d of %s is not a C-array of with length in arg %d"%(
                 argno, method, count))
 
+    def failUnlessResultSizeInArg(self, method, count, message=None):
+        if isinstance(method, objc.selector):
+            offset = 2
+        else:
+            offset = 0
+        info = method.__metadata__()
+        cnt = info['retval']['c_array_length_in_arg']
+        if cnt != count + offset:
+            self.fail(message or "result %s is not a C-array of with length in arg %d"%(
+                argno, method, count))
+
 
     def failUnlessArgIsOut(self, method, argno, message=None):
         if isinstance(method, objc.selector):

Modified: trunk/pyobjc/pyobjc-core/Lib/objc/_convenience.py
==============================================================================
--- trunk/pyobjc/pyobjc-core/Lib/objc/_convenience.py	(original)
+++ trunk/pyobjc/pyobjc-core/Lib/objc/_convenience.py	Sat Mar 28 12:12:38 2009
@@ -32,7 +32,7 @@
     Add the list with methods to every class that has a selector with the
     given name.
     """
-    CONVENICENCE_METHODS[selector] = methods
+    CONVENIENCE_METHODS[selector] = methods
 
 def addConvenienceForClass(classname, methods):
     """

------------------------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.