Layers

zope.component.testlayer defines two things:

  • a LayerBase that makes it easier and saner to use zope.testing’s test layers.
  • a ZCMLLayer which lets you implement a layer that loads up some ZCML.

LayerBase

We check whether our LayerBase can be used to create layers of our own. We do this simply by subclassing:

Note that if we wanted to ensure that the methods of the superclass were called we have to use super(). In this case we actually wouldn’t need to, as these methods do nothing at all, but we just ensure that they are there in the first place.

Let’s instantiate our layer. We need to supply it with the package the layer is defined in:

Now we run some tests with this layer:

ZCMLLayer

We now want a layer that loads up some ZCML from a file. The default is ftesting.zcml, but here we’ll load a test testlayer.zcml.

Since the ZCML sets up an adapter, we expect the tests to pass: