On Jul 4, 1:25 pm, Craig Small <[email protected]> wrote:
> Hi,
> I've been struggling with writing tests for a Child object that has
> a mandatory Parent. The problem is usually around the Child having
> something like
> parent_id = Column(Integer, ForeignKey('parents.id'), nullable=False)
>
> Probably very sensible from an application viewpoint but testing always
> breaks because it only creates one object at a time.
>
> I'm not sure if it is the right way, but this seemed to work for testing
> the Child.
>
> class TestChild(ModelTest):
> klass = model.Child
> test_parent = model.Parent()
>
> attribs = dict(
> parent = test_parent
>
class TestChild(ModelTest):
klass = model.Child
def do_get_dependencies(self):
parent = model.Parent()
return {'parent': parent}
should work also
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en.