On Fri, 2003-05-30 at 21:53, Edmund Lian wrote:
> Ian Bicking wrote:
>
> > Okay, *this* time! Finally wrote the dumb unit test...
>
> Almost there! :-) I have one failure:
>
> >>> from test import *
> >>> cc = ComponentCategory.new(name="CAT")
> >>> cc
> <ComponentCategory 3 name='CAT' description=None sequenceNum=None>
>
>
> Create component with default None for category:
>
> >>> c = Component.new(name="Mad")
> >>> c
> <Component 9 name='Mad' categoryId=None sequenceNum=None>
> >>> c.category
>
>
>
> Try assigning instance of ComponentCategory to category attribute:
>
> >>> c.category = cc
> >>> c.category
> <ComponentCategory 3 name='CAT' description=None sequenceNum=None>
>
>
> Now try creating component while passing in an instance of
> ComponentCategory:
>
>
> >>> c = Component.new(name="Mad", category=cc)
> >>> c
> <Component 10 name='Mad' categoryId='3' sequenceNum=None>
> >>> c.category
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File "/usr/lib/python2.2/site-packages/SQLObject/SQLObject.py", line
> 928, in __repr__
> ' '.join(['%s=%s' % (name, repr(value)) for name, value in
> self._reprItems()]))
> TypeError: an integer is required
Something weird is going on here. Note:
<Component 10 name='Mad' categoryId='3' sequenceNum=None>
categoryId is '3', not the integer 3. Why is this happening? That
seems to be the problem, but it shouldn't be possible to get a
non-integer in there. Unless cc was already messed up before it got
assigned, and its id was '3'. Component('3') would very possibly
work... maybe there should be an assert somewhere to avoid this... I
assume that happened in some step you're not showing.
Ian
|