ExtensionClass is not of type Class?!
Hi, I guess I'm doing something wrong here trying to write tests for Squishdot: Traceback (most recent call last): File "testSquishfile.py", line 16, in testAddFile assert isinstance(theFile,Squishfile) TypeError: isinstance() arg 2 must be a class or type Given the above, I put a "print Squishfile" in the line above the assert, it gave: <extension class Products.Squishdot.Squishfile.Squishfile at 010ABC48> So are extension classes not usuable with isinstance? If not, what should I be doing to check I'm creating an object of the right type? If they are usuable, then what am I doing wrong? cheers, Chris
TypeError: isinstance() arg 2 must be a class or type
Given the above, I put a "print Squishfile" in the line above the assert, it gave:
<extension class Products.Squishdot.Squishfile.Squishfile at 010ABC48>
So are extension classes not usuable with isinstance?
The Python 1.5.2 isinstance does not recognize Extension Classes (it works as expected as of Python 2.x).
If not, what should I be doing to check I'm creating an object of the right type?
A workable hack would be: assert ob.__class__ is theClass Brian Lloyd brian@zope.com Zope Corporation www.zope.com
Brian Lloyd wrote:
So are extension classes not usuable with isinstance?
The Python 1.5.2 isinstance does not recognize Extension Classes (it works as expected as of Python 2.x).
I'm sure this was with Zope 2.4.0 on WinNT, so Python 2.1 :-S
A workable hack would be:
assert ob.__class__ is theClass
I actually ended up replacing it with: assert ob.meta_type == 'Squishdot File' cheers, Chris
participants (2)
-
Brian Lloyd -
Chris Withers