[Pyobjc-dev] Dubious unittest
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2003-12-27 15:46:06
|
Background: objc.classAddMethods can be used to add new methods to an Objective-C class (like categories in Objective-C). One of the unittests does something like this: # Start of code class NewMethods: def method1(self): pass objc.classAddMethods(NSObject, [ NewMethods.method1 ]) # End of code This unittests fails because of an exception when trying to use NSObject.method1. This raises and exception because NSObject.method1 is actually an method of NewMethods and self is therefore of the wrong type. The same effect can be observed like this: # Start of code class C1: def printme(self): print "me" class C2: pass C2.printme = C1.printme c = C2() c.printme() # End of code It would be possible to change the code so that the unittest would pass, but given the behaviour of normal class I'd prefer to declare the current behaviour correct. Ronald |