nti.testing.layers#
Test layer support.
Changed in version 4.0.0: This is now a package with sub-modules. Existing imports continue to work.
- nti.testing.layers.find_test()[source]#
The layer support in
nose2.plugins.layers.Layers
optionally supplies the test case object totestSetUp
andtestTearDown
, butzope.testrunner
does not do this. If you need access to the test, you can use an idiom like this:@classmethod def testSetUp(cls, test=None): test = test or find_test()
Test layers for working with Zope libraries.
- class nti.testing.layers.zope.ConfiguringLayerMixin[source]#
Bases:
AbstractConfiguringObject
Inherit from this layer at the leaf level to perform configuration. You should have already inherited from
ZopeComponentLayer
.To use this layer, subclass it and define a set of packages. This should be done EXACTLY ONCE for each set of packages; things that add to the set of packages should generally extend that layer class. You must call
setUpPackages()
andtearDownPackages()
from yoursetUp
andtearDown
methods.See
AbstractConfiguringObject
for documentation on the class attributes to configure.- classmethod get_configuration_package()#
-
New in version 2.1.0.
- class nti.testing.layers.zope.ZopeComponentLayer[source]#
Bases:
SharedCleanupLayer
Test layer that can be subclassed when zope.component will be used.
This does nothing but set up the hooks and the event handlers.
- classmethod testSetUp()[source]#
Calls
sharedCleanup()
for every test.
- classmethod testTearDown()[source]#
Calls
sharedCleanup()
for every test.
Support for cleaning up:
Garbage collection
Registered cleanups.
New in version 4.0.0.
- class nti.testing.layers.cleanup.GCLayerMixin[source]#
Bases:
object
Mixin this layer class and call
setUpGC()
from your layersetUp
method and likewise for the teardowns when you want to do GC.- classmethod setUpGC()[source]#
This method disables GC until
tearDownGC()
is called. You should call it from your layersetUp
method.It also cleans up the zope.testing state.
Bases:
object
Mixin this layer when you need cleanup functions that run for every test.
Calls
sharedCleanup()
for every test.
Calls
sharedCleanup()
for every test.