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 to testSetUp and testTearDown, but zope.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() and tearDownPackages() from your setUp and tearDown methods.

See AbstractConfiguringObject for documentation on the class attributes to configure.

classmethod get_configuration_package()#

New in version 2.1.0.

classmethod setUpPackages()[source]#

Set up the configured packages.

classmethod tearDownPackages()[source]#

Tear down all configured packages in the global site manager.

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 layer setUp 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 layer setUp method.

It also cleans up the zope.testing state.

classmethod tearDownGC()[source]#

This method executes zope.testing’s cleanup and then renables GC. You should call if from your layer tearDown method.

class nti.testing.layers.cleanup.SharedCleanupLayer[source]#

Bases: object

Mixin this layer when you need cleanup functions that run for every test.

classmethod testSetUp()[source]#

Calls sharedCleanup() for every test.

classmethod testTearDown()[source]#

Calls sharedCleanup() for every test.