[Zope-dev] Zope test layers, pytest, and test isolation
Godefroid Chapelle
gotcha at bubblenet.be
Thu Mar 24 07:13:21 EDT 2011
Hi Uli,
I am happy that some people started to look what is needed to make
modular component registrations with py.test.
The long explanation that you wrote made it easy for me to jump into
funcargs.
Those last months, I have been diving into the great plone.testing
package written by Martin Aspeli.
Among others, plone.testing has a very nice module zca.py to ease
building zope.testing layers that need ZCA.
See
https://dev.plone.org/plone/browser/plone.testing/trunk/src/plone/testing/zca.py
Specifically, pushGlobalRegistry and popGlobalRegistry are a pair of
functions that allow to make registrations step by step, while easily
throwing away the latest registrations when they are not needed anymore.
plone.testing does not depend on Zope2 even if it comes with support for
building Zope2 layers.
Le 24/03/11 01:05, Uli Fouquet a écrit :
> Compared to Zope test layers I came to the conclusion that there is not
> much like this concept already in `pytest` and the behaviour of test
> layers can not easily be faked. `pytest` provides only the three
> mentioned scopes as kind of 'natural' layers. Spreading fixtures over
> many modules (as layers easily do) might contradict with the basic
> design goals of pytest and I am pretty sure that Holge Krekel wouldn't
> like it.
I do not agree with that last statement : the fact that resources can be
cached during a session allows them to be reused over many modules. IOW,
it does not contradict pytest design.
Digging into funcargs gives me the feeling that they are much richer
than layers.
Because funcargs are functions that get access to a lot of context, they
allow for more flexibility than layers that are only static resources.
> Overall, we're now looking for a satisfying solution in terms of runtime
> and isolation. Some of the questions that arise:
My feeling is that the extrakey argument of cached_setup can be used in
combination with code similar to plone.testing ZCA support to build
something "satisfying in terms of runtime and isolation."
>
> Would it make sense to bring the Zope layer concept into `pytest`?
I think what is already available in py.test might avoid the need of layers.
> Are there already possibilities to mimic testlayer-like behaviour in
> `pytest` which we simply overlooked?
See above.
>
> Are there cheap/fast ways to cache/restore registry setups we hadn't had
> on the screen? Really fast setups/cache-restores could make even
> function-wise registrations a considerable thing.
>
> Would it simply be okay to use the 'module' scope for registration
> setups?
>
> Or do you have completely different ideas how to solve that issue?
>
> Any comments are really appreciated!
>
> Best regards,
>
> -- Uli
--
Godefroid Chapelle (aka __gotcha) http://bubblenet.be
More information about the Zope-Dev
mailing list