[Grok-dev] How does one unittest a view?

Wichert Akkerman wichert at wiggy.net
Wed Apr 8 11:09:23 EDT 2009


Previously Jan-Wijbrand Kolman wrote:
> Would just grokking the View component itself be acceptable?
> 
> If so, I think you could do:
> 
>   from grokcore.component.testing import grok_component
> 
>   def setUp(self):
>     grok_component('View', View)
> 
> But this still involves having CA registrations taking place and it
> seems that that is not what you want *at all*, right?

Preferably not.

> In that case yes, Grok makes it not easy to write a "pure" unittests for
> view components.
> 
> I wonder how this would work in a vanilla Zope 3 context though...

One uses zope.component.testing.PlacelessSetup and manually calls
provideAdapter & friends when needed.

Wichert.

-- 
Wichert Akkerman <wichert at wiggy.net>    It is simple to make things.
http://www.wiggy.net/                   It is hard to make things simple.


More information about the Grok-dev mailing list