def fix_plonetestcase_mess():
    """Registers a Products.PloneTestCase cleanup.
    It is a nested teardown so that we can meake sure that it is executate
    as last tear down function.
    """
    def reset_zope2():
        """Testing.ZopeTestCase.layer.ZopeLite does not support tearing down.
        This results in a partically teared down Zope2 instance.
        This function resets the Zope2 initialization state so that we can
        initialize another Zope2 instance with p.a.testing.
        """
        import Zope2
        Zope2._began_startup = 0
    onteardown(reset_zope2)()
def fix_plonetestcase_mess():
    """Registers a Products.PloneTestCase cleanup.
    It is a nested teardown so that we can meake sure that it is executate
    as last tear down function.
    """
    def reset_zope2():
        """Testing.ZopeTestCase.layer.ZopeLite does not support tearing down.
        This results in a partically teared down Zope2 instance.
        This function resets the Zope2 initialization state so that we can
        initialize another Zope2 instance with p.a.testing.
        """
        import Zope2
        Zope2._began_startup = 0

    onteardown(reset_zope2)()
def fix_plonetestcase_mess():
    """Registers a Products.PloneTestCase cleanup.
    It is a nested teardown so that we can meake sure that it is executate
    as last tear down function.
    """
    def reset_zope2():
        """Testing.ZopeTestCase.layer.ZopeLite does not support tearing down.
        This results in a partically teared down Zope2 instance.
        This function resets the Zope2 initialization state so that we can
        initialize another Zope2 instance with p.a.testing.
        """
        import Zope2
        Zope2._began_startup = 0
    onteardown(reset_zope2)()
onteardown(fix_plonetestcase_mess)()


TEST_CONTENT_TYPE_ID = 'TestContentType'
DEFAULT_POLICIES = ('at_edit_autoversion', 'version_on_revert',)


class VersioningLayer(PloneSandboxLayer):
    defaultBases = (PLONE_FIXTURE,)

    def setUpZope(self, app, configurationContext):
        import plone.app.versioningbehavior
        xmlconfig.file('configure.zcml', plone.app.versioningbehavior,
                       context=configurationContext)

    def setUpPloneSite(self, portal):
    It is a nested teardown so that we can meake sure that it is executate
    as last tear down function.
    """
    def reset_zope2():
        """Testing.ZopeTestCase.layer.ZopeLite does not support tearing down.
        This results in a partically teared down Zope2 instance.
        This function resets the Zope2 initialization state so that we can
        initialize another Zope2 instance with p.a.testing.
        """
        import Zope2
        Zope2._began_startup = 0

    onteardown(reset_zope2)()


onteardown(fix_plonetestcase_mess)()

TEST_CONTENT_TYPE_ID = 'TestContentType'
DEFAULT_POLICIES = (
    'at_edit_autoversion',
    'version_on_revert',
)


class VersioningLayer(PloneSandboxLayer):
    defaultBases = (PLONE_FIXTURE, )

    def setUpZope(self, app, configurationContext):
        import plone.app.versioningbehavior
        xmlconfig.file('configure.zcml',
                       plone.app.versioningbehavior,