Package: plone.app.testing
IntroductionTable of contentsIntroductionCompatibilityInstallation and usageLayer referencePlone site fixtureMock MailHostPloneWithPackageLayer classIntegration and functional testing test lifecyclesPlone integration testingPlone functional testingPlone ZServerPlone FTP serverHelper functionsPlone site context managerUser managementProduct and profile installationComponent architecture sandboxingGlobal state cleanupLayer base classCommon test patternsBasic content managementSearchingUser managementPermissions and rolesWorkflowPropertiesInstalling products and extension profilesTraversalSimulating browser interactionDebugging tipsComparison with ZopeTestCase/PloneTestCaseChangelog7.0.2 (2024-01-19)7.0.1 (2023-04-15)7.0.0 (2022-12-02)7.0.0b2 (2022-10-11)7.0.0b1 (2022-09-30)7.0.0a3 (2022-04-28)7.0.0a2 (2022-04-04)7.0.0a1 (2022-03-23)6.1.9 (2021-09-01)6.1.8 (2020-11-11)6.1.7 (2020-10-12)6.1.6 (2020-09-26)6.1.5 (2020-04-20)6.1.4 (2020-03-09)6.1.3 (2019-02-16)6.1.2 (2019-02-13)6.1.1 (2018-11-05)6.1.0 (2018-11-04)6.0.0 (2018-10-05)5.0.8 (2017-10-25)5.0.7 (2017-07-03)5.0.6 (2016-12-19)5.0.5 (2016-11-19)5.0.4 (2016-09-23)5.0.3 (2016-09-07)5.0.2 (2016-06-07)5.0.1 (2016-02-26)5.0.0 (2016-02-20)5.0b6 (2015-08-22)5.0b5 (2015-07-18)5.0b4 (2015-05-04)5.0b3 (2015-03-26)5.0b2 (2015-03-13)5.0b1 (2014-10-23)5.0a2 (2014-04-19)5.0a1 (2014-02-22)4.2.2 (2013-02-09)4.2.1 (2012-12-15)4.2 (2012-04-15)4.0.2 (2011-08-31)4.0.1 (2011-07-14)4.0 - 2011-05-134.0a6 - 2011-04-064.0a5 - 2011-03-024.0a4 - 2011-01-114.0a3 - 2010-12-141.0a2 - 2010-09-051.0a1 - 2010-08-01plone.app.testingprovides tools for writing integration and functional
tests for code that runs on top of Plone. It is based onplone.testing.
If you are unfamiliar withplone.testing, the concept of layers, or thezope.testingtestrunner, please take a look at the theplone.testingdocumentation. In fact, even if you are working exclusively with Plone, you
are likely to want to use some of its features for unit testing.In short,plone.app.testingincludes:A set of layers that set up fixtures containing a Plone site, intended for
writing integration and functional tests.A collection of helper functions, some useful for writing your own layers
and some applicable to tests themselves.A convenient layer base class, extendingplone.testing.Layer, which
makes it easier to write custom layers extending the Plone site fixture,
with proper isolation and tear-down.Cleanup hooks forzope.testing.cleanupto clean up global state found
in a Plone installation. This is useful for unit testing.Compatibilityplone.app.testing5.x works with Plone 5.plone.app.testing4.x works with Plone 4 and Zope 2.12. It may work with
newer versions. It will not work with earlier versions. Useplone.app.testing3.x for Plone 3 and Zope 2.10.Installation and usageTo useplone.app.testingin your own package, you need to add it as a
dependency. Most people prefer to keep test-only dependencies separate, so
that they do not need to be installed in scenarios (such as on a production
server) where the tests will not be run. This can be achieved using atestextra.Insetup.py, add or modify theextras_requireoption, like so:extras_require = {
    'test': [
            'plone.app.testing',
        ]
},This will also includeplone.testing, with the[z2],[zca]and[zodb]extras (whichplone.app.testingitself relies on).Please see theplone.testingdocumentation for more details about how to
add a test runner to your buildout, and how to write and run tests.Layer referenceThis package contains a layer class,plone.app.testing.layers.PloneFixture, which sets up a Plone site fixture.
It is combined with other layers fromplone.testingto provide a number of
layer instances. It is important to realise that these layers all have the
same fundamental fixture: they just manage test setup and tear-down
differently.When set up, the fixture will:Create a ZODB sandbox, via a stackedDemoStorage. This ensures
persistent changes made during layer setup can be cleanly torn down.Configure a global component registry sandbox. This ensures that global
component registrations (e.g. as a result of loading ZCML configuration)
can be cleanly torn down.Create a configuration context with thedisable-autoincludefeature
set. This has the effect of stopping Plone from automatically loading the
configuration of any installed package that uses thez3c.autoinclude.plugin:ploneentry point viaz3c.autoinclude. (This
is to avoid accidentally polluting the test fixture - custom layers should
load packages’ ZCML configuration explicitly if required).Install a number of Zope 2-style products on which Plone depends.Load the ZCML for these products, and forProducts.CMFPlone, which in
turn pulls in the configuration for the core of Plone.Create a default Plone site, with the default theme enabled, but with no
default content.Add a user to the root user folder with theManagerrole.Add a test user to this instance with theMemberrole.For each test:The test user is logged inThe local component site is setVarious global caches are cleaned upVarious constants in the moduleplone.app.testing.interfacesare defined
to describe this environment:ConstantPurposePLONE_SITE_IDThe id of the Plone site object inside the Zope
application root.PLONE_SITE_TITLEThe title of the Plone siteDEFAULT_LANGUAGEThe default language of the Plone site (‘en’)TEST_USER_IDThe id of the test userTEST_USER_NAMEThe username of the test userTEST_USER_PASSWORDThe password of the test userTEST_USER_ROLESThe default global roles of the test user -
(‘Member’,)SITE_OWNER_NAMEThe username of the user owning the Plone site.SITE_OWNER_PASSWORDThe password of the user owning the Plone site.All the layers also expose a resource in addition to those from their
base layers, made available during tests:portalThe Plone site root.Plone site fixtureLayer:plone.app.testing.PLONE_FIXTUREClass:plone.app.testing.layers.PloneFixtureBases:plone.testing.z2.STARTUPResources:This layer sets up the Plone site fixture on top of thez2.STARTUPfixture.You should not use this layer directly, as it does not provide any test
lifecycle or transaction management. Instead, you should use a layer
created with either theIntegrationTestingorFunctionalTestingclasses, as outlined below.Mock MailHostLayer:plone.app.testing.MOCK_MAILHOST_FIXTUREClass:plone.app.testing.layers.MockMailHostLayerBases:plone.app.testing.layers.PLONE_FIXTUREResources:This layer builds on top ofPLONE_FIXTUREto patch Plone’s MailHost implementation.With it,
any attempt to send an email will instead store each of them as a string in a list inportal.MailHost.messages.You should not use this layer directly, as it does not provide any test
lifecycle or transaction management. Instead, you should use a layer
created with either theIntegrationTestingorFunctionalTestingclasses, like:from plone.app.testing import MOCK_MAILHOST_FIXTURE

MY_INTEGRATION_TESTING = IntegrationTesting(
    bases=(
        MY_FIXTURE,
        MOCK_MAILHOST_FIXTURE,
    ),
    name="MyFixture:Integration"
)PloneWithPackageLayer classMost add-ons do not need more setup than loading a ZCML file and
running a GenericSetup profile.With this helper class, a fixture can easily be instantiated:from plone.app.testing import PloneWithPackageLayer
import my.addon

FIXTURE = PloneWithPackageLayer(
    zcml_package=my.addon,
    zcml_filename='configure.zcml',
    gs_profile_id='my.addon:default',
    name="MyAddonFixture"
)PloneWithPackageLayer constructor takes two other keyword arguments:basesandadditional_z2_products.Thebasesargument takes a sequence of base layer fixtures.
It is useful, among other reasons,
to pass a fixture which makes other calls to plone.app.testing API.
The need could arise in the development process.additional_z2_productsargument takes a sequence of package names
that need to be installed as Zope2 Products and are dependencies of the tested add-on.Integration and functional testing test lifecyclesplone.app.testingcomes with two layer classes,IntegrationTestingandFunctionalTesting, which derive from the corresponding layer classes
inplone.testing.z2.These classes set up theapp,requestandportalresources, and
reset the fixture (including various global caches) between each test run.As with the classes inplone.testing, theIntegrationTestingclass
will create a new transaction for each test and roll it back on test tear-
down, which is efficient for integration testing, whilstFunctionalTestingwill create a stackedDemoStoragefor each test and pop it on test tear-
down, making it possible to exercise code that performs an explicit commit
(e.g. via tests that usezope.testbrowser).When creating a custom fixture, the usual pattern is to create a new layer
class that hasPLONE_FIXTUREas its default base, instantiating that as a
separate “fixture” layer. This layer is not to be used in tests directly,
since it won’t have test/transaction lifecycle management, but represents a
shared fixture, potentially for both functional and integration testing. It
is also the point of extension for other layers that follow the same pattern.Once this fixture has been defined, “end-user” layers can be defined using
theIntegrationTestingandFunctionalTestingclasses. For example:from plone.testing import Layer
from plone.app.testing import PLONE_FIXTURE
from plone.app.testing import IntegrationTesting, FunctionalTesting

class MyFixture(Layer):
    defaultBases = (PLONE_FIXTURE,)

    ...

MY_FIXTURE = MyFixture()

MY_INTEGRATION_TESTING = IntegrationTesting(bases=(MY_FIXTURE,), name="MyFixture:Integration")
MY_FUNCTIONAL_TESTING = FunctionalTesting(bases=(MY_FIXTURE,), name="MyFixture:Functional")See thePloneSandboxLayerlayer below for a more comprehensive example.Plone integration testingLayer:plone.app.testing.PLONE_INTEGRATION_TESTINGClass:plone.app.testing.layers.IntegrationTestingBases:plone.app.testing.PLONE_FIXTUREResources:portal(test setup only)This layer can be used for integration testing against the basicPLONE_FIXTURElayer.You can use this directly in your tests if you do not need to set up any
other shared fixture.However, you would normally not extend this layer - see above.Plone functional testingLayer:plone.app.testing.PLONE_FUNCTIONAL_TESTINGClass:plone.app.testing.layers.FunctionalTestingBases:plone.app.testing.PLONE_FIXTUREResources:portal(test setup only)This layer can be used for functional testing against the basicPLONE_FIXTURElayer, for example usingzope.testbrowser.You can use this directly in your tests if you do not need to set up any
other shared fixture.Again, you would normally not extend this layer - see above.Plone ZServerLayer:plone.app.testing.PLONE_ZSERVERClass:plone.testing.z2.ZServerBases:plone.app.testing.PLONE_FUNCTIONAL_TESTINGResources:portal(test setup only)This is layer is intended for functional testing using a live, running HTTP
server, e.g. using Selenium or Windmill.Again, you would not normally extend this layer. To create a custom layer
that has a running ZServer, you can use the same pattern as this one, e.g.:from plone.testing import Layer
from plone.testing import z2
from plone.app.testing import PLONE_FIXTURE
from plone.app.testing import FunctionalTesting

class MyFixture(Layer):
    defaultBases = (PLONE_FIXTURE,)

    ...

MY_FIXTURE = MyFixture()
MY_ZSERVER = FunctionalTesting(bases=(MY_FIXTURE, z2.ZSERVER_FIXTURE), name='MyFixture:ZServer')See the description of thez2.ZSERVERlayer inplone.testingfor further details.Plone FTP serverLayer:plone.app.testing.PLONE_FTP_SERVERClass:plone.app.testing.layers.FunctionalTestingBases:plone.app.testing.PLONE_FIXTUREplone.testing.z2.ZSERVER_FIXTUREResources:portal(test setup only)This is layer is intended for functional testing using a live FTP server.It is semantically equivalent to thePLONE_ZSERVERlayer.See the description of thez2.FTP_SERVERlayer inplone.testingfor further details.Helper functionsA number of helper functions are provided for use in tests and custom layers.Plone site context managerploneSite(db=None, connection=None, environ=None)Use this context manager to access and make changes to the Plone site
during layer setup. In most cases, you will use it without arguments,
but if you have special needs, you can tie it to a particular database
instance. See the description of thezopeApp()context manager inplone.testing(which this context manager uses internally) for details.The usual pattern is to call it duringsetUp()ortearDown()in
your own layers:from plone.testing import Layer
from plone.app.testing import ploneSite

class MyLayer(Layer):

    def setUp(self):

        ...

        with ploneSite() as portal:

            # perform operations on the portal, e.g.
            portal.title = u"New title"Here,portalis the Plone site root. A transaction is begun before
entering thewithblock, and will be committed upon exiting the block,
unless an exception is raised, in which case it will be rolled back.Inside the block, the local component site is set to the Plone site root,
so that local component lookups should work.Warning:Do not attempt to load ZCML files inside aploneSiteblock. Because the local site is set to the Plone site, you may end up
accidentally registering components in the local site manager, which can
cause pickling errors later.Note:You should not use this in a test, or in atestSetUp()ortestTearDown()method of a layer based on one of the layer in this
package. Use theportalresource instead.Also note:If you are writing a layer setting up a Plone site fixture,
you may want to use thePloneSandboxLayerlayer base class, and
implement thesetUpZope(),setUpPloneSite(),tearDownZope()and/ortearDownPloneSite()methods instead. See below.User managementlogin(portal, userName)Simulate login as the given user. This is based on thez2.login()helper inplone.testing, but instead of passing a specific user folder,
you pass the portal (e.g. as obtained via theportallayer resource).For example:import unittest2 as unittest

from plone.app.testing import PLONE_INTEGRATION_TESTING
from plone.app.testing import TEST_USER_NAME
from plone.app.testing import login

...

class MyTest(unittest.TestCase):

    layer = PLONE_INTEGRATION_TESTING

    def test_something(self):
        portal = self.layer['portal']
        login(portal, TEST_USER_NAME)

        ...logout()Simulate logging out, i.e. becoming the anonymous user. This is equivalent
to thez2.logout()helper inplone.testing.For example:import unittest2 as unittest

from plone.app.testing import PLONE_INTEGRATION_TESTING
from plone.app.testing import logout

...

class MyTest(unittest.TestCase):

    layer = PLONE_INTEGRATION_TESTING

    def test_something(self):
        portal = self.layer['portal']
        logout()

        ...setRoles(portal, userId, roles)Set the roles for the given user.rolesis a list of roles.For example:import unittest2 as unittest

from plone.app.testing import PLONE_INTEGRATION_TESTING
from plone.app.testing import TEST_USER_ID
from plone.app.testing import setRoles

...

class MyTest(unittest.TestCase):

    layer = PLONE_INTEGRATION_TESTING

    def test_something(self):
        portal = self.layer['portal']
        setRoles(portal, TEST_USER_ID, ['Manager'])Product and profile installationapplyProfile(portal, profileName, blacklisted_steps=None)Install a GenericSetup profile (usually an extension profile) by name,
using theportal_setuptool. The name is normally made up of a package
name and a profile name. Do not use theprofile-prefix.For example:from plone.testing import Layer

from plone.app.testing import ploneSite
from plone.app.testing import applyProfile

...

class MyLayer(Layer):

    ...

    def setUp(self):

        ...

        with ploneSite() as portal:
            applyProfile(portal, 'my.product:default')

            ...quickInstallProduct(portal, productName, reinstall=False)Use this function to install a particular product into the given Plone site,
using the add-ons control panel code (portal setup).
IfreinstallisFalseand the product is already installed, nothing will happen.
Ifreinstallis true, perform an uninstall and install if the product is installed already.
TheproductNameshould be a full dotted name, e.g.Products.MyProduct,
ormy.product.For example:from plone.testing import Layer

from plone.app.testing import ploneSite
from plone.app.testing import quickInstallProduct

...

class MyLayer(Layer):

    ...

    def setUp(self):

        ...

        with ploneSite() as portal:
            quickInstallProduct(portal, 'my.product')

            ...Component architecture sandboxingpushGlobalRegistry(portal, new=None, name=None)Create or obtain a stack of global component registries, and push a new
registry to the top of the stack. This allows Zope Component Architecture
registrations (e.g. loaded via ZCML) to be effectively torn down.If you are going to use this function, please read the corresponding
documentation forzca.pushGlobalRegistry()inplone.testing. In
particular, note that youmustreciprocally callpopGlobalRegistry()(see below).This helper is based onzca.pushGlobalRegistry(), but will also fix
up the local component registry in the Plone siteportalso that it
has the correct bases.For example:from plone.testing import Layer

from plone.app.testing import ploneSite
from plone.app.testing import pushGlobalRegistry
from plone.app.testing import popGlobalRegistry

...

class MyLayer(Layer):

    ...

    def setUp(self):

        ...

        with ploneSite() as portal:
            pushGlobalRegistry(portal)

            ...popGlobalRegistry(portal)Tear down the top of the component architecture stack, as created withpushGlobalRegistry()For example:...

    def tearDown(self):

        with ploneSite() as portal:
            popGlobalRegistry(portal)Global state cleanuptearDownMultiPluginRegistration(pluginName)PluggableAuthService “MultiPlugins” are kept in a global registry. If
you have registered a plugin, e.g. using theregisterMultiPlugin()API, you should tear that registration down in your layer’stearDown()method. You can use this helper, passing a plugin name.For example:from plone.testing import Layer

from plone.app.testing import ploneSite
from plone.app.testing import tearDownMultiPluginRegistration

...

class MyLayer(Layer):

    ...

    def tearDown(self):

        tearDownMultiPluginRegistration('MyPlugin')

        ...Layer base classIf you are writing a custom layer to test your own Plone add-on product, you
will often want to do the following on setup:Stack a newDemoStorageon top of the one from the base layer. This
ensures that any persistent changes performed during layer setup can be
torn down completely, simply by popping the demo storage.Stack a new ZCML configuration context. This keeps separate the information
about which ZCML files were loaded, in case other, independent layers want
to load those same files after this layer has been torn down.Push a new global component registry. This allows you to register
components (e.g. by loading ZCML or using the test API fromzope.component) and tear down those registration easily by popping the
component registry.Load your product’s ZCML configurationInstall the product into the test fixture Plone siteOf course, you may wish to make other changes too, such as creating some base
content or changing some settings.On tear-down, you will then want to:Remove any Pluggable Authentication Service “multi-plugins” that were added
to the global registry during setup.Pop the global component registry to unregister components loaded via ZCML.Pop the configuration context resource to restore its state.Pop theDemoStorageto undo any persistent changes.If you have made other changes on setup that are not covered by this broad
tear-down, you’ll also want to tear those down explicitly here.Stacking a demo storage and component registry is the safest way to avoid
fixtures bleeding between tests. However, it can be tricky to ensure that
everything happens in the right order.To make things easier, you can use thePloneSandboxLayerlayer base class.
This extendsplone.testing.Layerand implementssetUp()andtearDown()for you. You simply have to override one or more of the
following methods:setUpZope(self, app, configurationContext)This is called during setup.appis the Zope application root.configurationContextis a newly stacked ZCML configuration context.
Use this to load ZCML, install products using the helperplone.testing.z2.installProduct(), or manipulate other global state.setUpPloneSite(self, portal)This is called during setup.portalis the Plone site root as
configured by theploneSite()context manager. Use this to make
persistent changes inside the Plone site, such as installing products
using theapplyProfile()orquickInstallProduct()helpers, or
setting up default content.tearDownZope(self, app)This is called during tear-down, before the global component registry and
stackedDemoStorageare popped. Use this to tear down any additional
global state.Note:Global component registrations PAS multi-plugin registrations are
automatically torn down. Product installations are not, so you should use
theuninstallProduct()helper if any products were installed duringsetUpZope().tearDownPloneSite(self, portal)This is called during tear-down, before the global component registry and
stackedDemoStorageare popped. During this method, the local
component site hook is set, giving you access to local components.Note:Persistent changes to the ZODB are automatically torn down by
virtue of a stackedDemoStorage. Thus, this method is less commonly
used than the others described here.Let’s show a more comprehensive example of what such a layer may look like.
Imagine we have a productmy.product. It has aconfigure.zcmlfile
that loads some components and registers aGenericSetupprofile, making it
installable in the Plone site. On layer setup, we want to load the product’s
configuration and install it into the Plone site.The layer would conventionally live in a moduletesting.pyat the root of
the package, i.e.my.product.testing:from plone.app.testing import PloneSandboxLayer
from plone.app.testing import PLONE_FIXTURE
from plone.app.testing import IntegrationTesting

from plone.testing import z2

class MyProduct(PloneSandboxLayer):

    defaultBases = (PLONE_FIXTURE,)

    def setUpZope(self, app, configurationContext):
        # Load ZCML
        import my.product
        self.loadZCML(package=my.product)

        # Install product and call its initialize() function
        z2.installProduct(app, 'my.product')

        # Note: you can skip this if my.product is not a Zope 2-style
        # product, i.e. it is not in the Products.* namespace and it
        # does not have a <five:registerPackage /> directive in its
        # configure.zcml.

    def setUpPloneSite(self, portal):
        # Install into Plone site using portal_setup
        self.applyProfile(portal, 'my.product:default')

    def tearDownZope(self, app):
        # Uninstall product
        z2.uninstallProduct(app, 'my.product')

        # Note: Again, you can skip this if my.product is not a Zope 2-
        # style product

MY_PRODUCT_FIXTURE = MyProduct()
MY_PRODUCT_INTEGRATION_TESTING = IntegrationTesting(bases=(MY_PRODUCT_FIXTURE,), name="MyProduct:Integration")Here,MY_PRODUCT_FIXTUREis the “fixture” base layer. Other layers can
use this as a base if they want to build on this fixture, but it would not
be used in tests directly. For that, we have created anIntegrationTestinginstance,MY_PRODUCT_INTEGRATION_TESTING.Of course, we could have created aFunctionalTestinginstance as
well, e.g.:MY_PRODUCT_FUNCTIONAL_TESTING = FunctionalTesting(bases=(MY_PRODUCT_FIXTURE,), name="MyProduct:Functional")Of course, we could do a lot more in the layer setup. For example, let’s say
the product had a content type ‘my.product.page’ and we wanted to create some
test content. We could do that with:from plone.app.testing import TEST_USER_ID
from plone.app.testing import TEST_USER_NAME
from plone.app.testing import login
from plone.app.testing import setRoles

...

    def setUpPloneSite(self, portal):

        ...

        setRoles(portal, TEST_USER_ID, ['Manager'])
        login(portal, TEST_USER_NAME)
        portal.invokeFactory('my.product.page', 'page-1', title=u"Page 1")
        setRoles(portal, TEST_USER_ID, ['Member'])

...Note that unlike in a test, there is no user logged in at layer setup time,
so we have to explicitly log in as the test user. Here, we also grant the test
user theManagerrole temporarily, to allow object construction (which
performs an explicit permission check).Note:Automatic tear down suffices for all the test setup above. If
the only changes made during layer setup are to persistent, in-ZODB data,
or the global component registry then no additional tear-down is required.
For any other global state being managed, you should write atearDownPloneSite()method to perform the necessary cleanup.Given this layer, we could write a test (e.g. intests.py) like:import unittest2 as unittest
from my.product.testing import MY_PRODUCT_INTEGRATION_TESTING

class IntegrationTest(unittest.TestCase):

    layer = MY_PRODUCT_INTEGRATION_TESTING

    def test_page_dublin_core_title(self):
        portal = self.layer['portal']

        page1 = portal['page-1']
        page1.title = u"Some title"

        self.assertEqual(page1.Title(), u"Some title")Please seeplone.testingfor more information about how to write and run
tests and assertions.Common test patternsplone.testing’s documentation contains details about the fundamental
techniques for writing tests of various kinds. In a Plone context, however,
some patterns tend to crop up time and again. Below, we will attempt to
catalogue some of the more commonly used patterns via short code samples.The examples in this section are all intended to be used in tests. Some may
also be useful in layer set-up/tear-down. We have usedunittestsyntax
here, although most of these examples could equally be adopted to doctests.We will assume that you are using a layer that hasPLONE_FIXTUREas a base
(whether directly or indirectly) and uses theIntegrationTestingorFunctionalTestingclasses as shown above.We will also assume that the variablesapp,portalandrequestare
defined from the relative layer resources, e.g. with:app = self.layer['app']
portal = self.layer['portal']
request = self.layer['request']Note that in a doctest set up using thelayered()function fromplone.testing,layeris in the global namespace, so you would do e.g.portal =layer['portal'].Where imports are required, they are shown alongside the code example. If
a given import or variable is used more than once in the same section, it
will only be shown once.Basic content managementTo create a content item of type ‘Folder’ with the id ‘f1’ in the root of
the portal:portal.invokeFactory('Folder', 'f1', title=u"Folder 1")Thetitleargument is optional. Other basic properties, likedescription, can be set as well.Note that this may fail with anUnauthorizedexception, since the test
user won’t normally have permissions to add content in the portal root, and
theinvokeFactory()method performs an explicit security check. You can
set the roles of the test user to ensure that he has the necessary
permissions:from plone.app.testing import setRoles
from plone.app.testing import TEST_USER_ID

setRoles(portal, TEST_USER_ID, ['Manager'])
portal.invokeFactory('Folder', 'f1', title=u"Folder 1")To obtain this object, acquisition-wrapped in its parent:f1 = portal['f1']To make an assertion against an attribute or method of this object:self.assertEqual(f1.Title(), u"Folder 1")To modify the object:f1.setTitle(u"Some title")To add another item inside the folder f1:f1.invokeFactory('Document', 'd1', title=u"Document 1")
d1 = f1['d1']To check if an object is in a container:self.assertTrue('f1' in portal)To delete an object from a container:del portal[‘f1’]There is no content or workflows installed by default. You can enable workflows:portal.portal_workflow.setDefaultChain("simple_publication_workflow")SearchingTo obtain theportal_catalogtool:from Products.CMFCore.utils import getToolByName

catalog = getToolByName(portal, 'portal_catalog')To search the catalog:results = catalog(portal_type="Document")Keyword arguments are search parameters. The result is a lazy list. You can
calllen()on it to get the number of search results, or iterate through
it. The items in the list are catalog brains. They have attributes that
correspond to the “metadata” columns configured for the catalog, e.g.Title,Description, etc. Note that these are simple attributes (not
methods), and contain the value of the corresponding attribute or method from
the source object at the time the object was cataloged (i.e. they are not
necessarily up to date).To make assertions against the search results:self.assertEqual(len(results), 1)

# Copy the list into memory so that we can use [] notation
results = list(results)

# Check the first (and in this case only) result in the list
self.assertEqual(results[0].Title, u"Document 1")To get the path of a given item in the search results:self.assertEqual(results[0].getPath(), portal.absolute_url_path() + '/f1/d1')To get an absolute URL:self.assertEqual(results[0].getURL(), portal.absolute_url() + '/f1/d1')To get the original object:obj = results[0].getObject()To re-index an object d1 so that its catalog information is up to date:d1.reindexObject()User managementTo create a new user:from Products.CMFCore.utils import getToolByName

acl_users = getToolByName(portal, 'acl_users')

acl_users.userFolderAddUser('user1', 'secret', ['Member'], [])The arguments are the username (which will also be the user id), the password,
a list of roles, and a list of domains (rarely used).To make a particular user active (“logged in”) in the integration testing
environment use theloginmethod and pass it the username:from plone.app.testing import login

login(portal, 'user1')To log out (become anonymous):from plone.app.testing import logout

logout()To obtain the current user:from AccessControl import getSecurityManager

user = getSecurityManager().getUser()To obtain a user by name:user = acl_users.getUser('user1')Or by user id (id and username are often the same, but can differ in real-world
scenarios):user = acl_users.getUserById('user1')To get the user’s user name:userName = user.getUserName()To get the user’s id:userId = user.getId()Permissions and rolesTo get a user’s roles in a particular context (taking local roles into
account):from AccessControl import getSecurityManager

user = getSecurityManager().getUser()

self.assertEqual(user.getRolesInContext(portal), ['Member'])To change the test user’s roles:from plone.app.testing import setRoles
from plone.app.testing import TEST_USER_ID

setRoles(portal, TEST_USER_ID, ['Member', 'Manager'])Pass a different user name to change the roles of another user.To grant local roles to a user in the folder f1:f1.manage_setLocalRoles(TEST_USER_ID, ('Reviewer',))To check the local roles of a given user in the folder ‘f1’:self.assertEqual(f1.get_local_roles_for_userid(TEST_USER_ID), ('Reviewer',))To grant the ‘View’ permission to the roles ‘Member’ and ‘Manager’ in the
portal root without acquiring additional roles from its parents:portal.manage_permission('View', ['Member', 'Manager'], acquire=False)This method can also be invoked on a folder or individual content item.To assert which roles have the permission ‘View’ in the context of the
portal:roles = [r['name'] for r in portal.rolesOfPermission('View') if r['selected']]
self.assertEqual(roles, ['Member', 'Manager'])To assert which permissions have been granted to the ‘Reviewer’ role in the
context of the portal:permissions = [p['name'] for p in portal.permissionsOfRole('Reviewer') if p['selected']]
self.assertTrue('Review portal content' in permissions)To add a new role:portal._addRole('Tester')This can now be assigned to users globally (using thesetRoleshelper)
or locally (usingmanage_setLocalRoles()).To assert which roles are available in a given context:self.assertTrue('Tester' in portal.valid_roles())WorkflowTo set the default workflow chain:from Products.CMFCore.utils import getToolByName

workflowTool = getToolByName(portal, 'portal_workflow')

workflowTool.setDefaultChain('my_workflow')In Plone, most chains contain only one workflow, but theportal_workflowtool supports longer chains, where an item is subject to more than one
workflow simultaneously.To set a multi-workflow chain, separate workflow names by commas.To get the default workflow chain:self.assertEqual(workflowTool.getDefaultChain(), ('my_workflow',))To set the workflow chain for the ‘Document’ type:workflowTool.setChainForPortalTypes(('Document',), 'my_workflow')You can pass multiple type names to set multiple chains at once. To set a
multi-workflow chain, separate workflow names by commas. To indicate that a
type should use the default workflow, use the special chain name ‘(Default)’.To get the workflow chain for the portal type ‘Document’:chains = dict(workflowTool.listChainOverrides())
defaultChain = workflowTool.getDefaultChain()
documentChain = chains.get('Document', defaultChain)

self.assertEqual(documentChain, ('my_other_workflow',))To get the current workflow chain for the content object f1:self.assertEqual(workflowTool.getChainFor(f1), ('my_workflow',))To update all permissions after changing the workflow:workflowTool.updateRoleMappings()To change the workflow state of the content object f1 by invoking the
transaction ‘publish’:workflowTool.doActionFor(f1, 'publish')Note that this performs an explicit permission check, so if the current user
doesn’t have permission to perform this workflow action, you may get an error
indicating the action is not available. If so, uselogin()orsetRoles()to ensure the current user is able to change the workflow
state.To check the current workflow state of the content object f1:self.assertEqual(workflowTool.getInfoFor(f1, 'review_state'), 'published')PropertiesTo set the value of a property on the portal root:portal._setPropValue('title', u"My title")To assert the value of a property on the portal root:self.assertEqual(portal.getProperty('title'), u"My title")To change the value of a property in a property sheet in theportal_propertiestool:from Products.CMFCore.utils import getToolByName

propertiesTool = getToolByName(portal, 'portal_properties')
siteProperties = propertiesTool['site_properties']

siteProperties._setPropValue('many_users', True)To assert the value of a property in a property sheet in theportal_propertiestool:self.assertEqual(siteProperties.getProperty('many_users'), True)Installing products and extension profilesTo apply a particular extension profile:from plone.app.testing import applyProfile

applyProfile(portal, 'my.product:default')This is the preferred method of installing a product’s configuration.To install an add-on product into the Plone site using the
add-ons control panel:from plone.app.testing import quickInstallProduct

quickInstallProduct(portal, 'my.product')To uninstall and install a product using the add-ons control panel:quickInstallProduct(portal, 'my.product', reinstall=True)Note that both of these assume the product’s ZCML has been loaded, which is
usually done during layer setup. See the layer examples above for more details
on how to do that.When writing a product that has an installation extension profile, it is often
desirable to write tests that inspect the state of the site after the profile
has been applied. Some of the more common such tests are shown below.To verify that a product has been installed (e.g. as a dependency viametadata.xml):from Products.CMFPlone.utils import get_installer

qi = get_installer(portal)
self.assertTrue(qi.is_product_installed('my.product'))To verify that a particular content type has been installed (e.g. viatypes.xml):typesTool = getToolByName(portal, 'portal_types')

self.assertNotEqual(typesTool.getTypeInfo('mytype'), None)To verify that a new catalog index has been installed (e.g. viacatalog.xml):catalog = getToolByName(portal, 'portal_catalog')

self.assertTrue('myindex' in catalog.indexes())To verify that a new catalog metadata column has been added (e.g. viacatalog.xml):self.assertTrue('myattr' in catalog.schema())To verify that a new workflow has been installed (e.g. viaworkflows.xml):workflowTool = getToolByName(portal, 'portal_workflow')

self.assertNotEqual(workflowTool.getWorkflowById('my_workflow'), None)To verify that a new workflow has been assigned to a type (e.g. viaworkflows.xml):self.assertEqual(dict(workflowTool.listChainOverrides())['mytype'], ('my_workflow',))To verify that a new workflow has been set as the default (e.g. viaworkflows.xml):self.assertEqual(workflowTool.getDefaultChain(), ('my_workflow',))To test the value of a property in theportal_propertiestool (e.g. set
viapropertiestool.xml)::propertiesTool = getToolByName(portal, 'portal_properties')
siteProperties = propertiesTool['site_properties']

self.assertEqual(siteProperties.getProperty('some_property'), "some value")To verify that a stylesheet has been installed in theportal_csstool
(e.g. viacssregistry.xml):cssRegistry = getToolByName(portal, 'portal_css')

self.assertTrue('mystyles.css' in cssRegistry.getResourceIds())To verify that a JavaScript resource has been installed in theportal_javascriptstool (e.g. viajsregistry.xml):jsRegistry = getToolByName(portal, 'portal_javascripts')

self.assertTrue('myscript.js' in jsRegistry.getResourceIds())To verify that a new role has been added (e.g. viarolemap.xml):self.assertTrue('NewRole' in portal.valid_roles())To verify that a permission has been granted to a given set of roles (e.g. viarolemap.xml):roles = [r['name'] for r in portal.rolesOfPermission('My Permission') if r['selected']]
self.assertEqual(roles, ['Member', 'Manager'])TraversalTo traverse to a view, page template or other resource, userestrictedTraverse()with a relative path:resource = portal.restrictedTraverse('f1/@@folder_contents')The return value is a view object, page template object, or other resource.
It may be invoked to obtain an actual response (see below).restrictedTraverse()performs an explicit security check, and so may
raiseUnauthorizedif the current test user does not have permission to
view the given resource. If you don’t want that, you can use:resource = portal.unrestrictedTraverse('f1/@@folder_contents')You can call this on a folder or other content item as well, to traverse from
that starting point, e.g. this is equivalent to the first example above:f1 = portal['f1']
resource = f1.restrictedTraverse('@@folder_contents')Note that this traversal will not takeIPublishTraverseadapters into
account, and you cannot pass query string parameters. In fact,restrictedTraverse()andunrestrictedTraverse()implement the type of
traversal that happens with path expressions in TAL, which is similar, but not
identical to URL traversal.To look up a view manually:from zope.component import getMultiAdapter

view = getMultiAdapter((f1, request), name=u"folder_contents")Note that the name here should not include the@@prefix.To simulate anIPublishTraverseadapter call, presuming the view
implementsIPublishTraverse:next = view.IPublishTraverse(request, u"some-name")Or, if theIPublishTraverseadapter is separate from the view:from zope.publisher.interfaces import IPublishTraverse

publishTraverse = getMultiAdapter((f1, request), IPublishTraverse)
next = view.IPublishTraverse(request, u"some-name")To simulate a form submission or query string parameters:request.form.update({
        'name': "John Smith",
        'age':  23
    })Theformdictionary contains the marshalled request. That is, if you are
simulating a query string parameter or posted form variable that uses a
marshaller like:int(e.g.age:intin the example above), the value
in theformdictionary should be marshalled (an int instead of a string,
in the example above), and the name should be the base name (ageinstead
ofage:int).To invoke a view and obtain the response body as a string:view = f1.restrictedTraverse('@@folder_contents')
body = view()

self.assertFalse(u"An unexpected error occurred" in body)Please note that this approach is not perfect. In particular, the request
is will not have the right URL or path information. If your view depends on
this, you can fake it by setting the relevant keys in the request, e.g.:request.set('URL', f1.absolute_url() + '/@@folder_contents')
request.set('ACTUAL_URL', f1.absolute_url() + '/@@folder_contents')To inspect the state of the request (e.g. after a view has been invoked):self.assertEqual(request.get('disable_border'), True)To inspect response headers (e.g. after a view has been invoked):response = request.response

self.assertEqual(response.getHeader('content-type'), 'text/plain')Simulating browser interactionEnd-to-end functional tests can usezope.testbrowserto simulate user
interaction. This acts as a web browser, connecting to Zope via a special
channel, making requests and obtaining responses.Note:zope.testbrowser runs entirely in Python, and does not simulate
a JavaScript engine.Note that to usezope.testbrowser, you need to use one of the functional
testing layers, e.g.PLONE_FUNCTIONAL_TESTING, or another layer
instantiated with theFunctionalTestingclass.If you want to create some initial content, you can do so either in a layer,
or in the test itself, before invoking the test browser client. In the latter
case, you need to commit the transaction before it becomes available, e.g.:from plone.app.testing import setRoles
from plone.app.testing import TEST_USER_ID

# Make some changes
setRoles(portal, TEST_USER_ID, ['Manager'])
portal.invokeFactory('Folder', 'f1', title=u"Folder 1")
setRoles(portal, TEST_USER_ID, ['Member'])

# Commit so that the test browser sees these changes
import transaction
transaction.commit()To obtain a new test browser client:from plone.testing.z2 import Browser

# This is usually self.app (Zope root) or site.portal (test Plone site root)
browser = Browser(app)To open a given URL:portalURL = portal.absolute_url()
browser.open(portalURL)To inspect the response:self.assertTrue(u"Welcome" in browser.contents)To inspect response headers:self.assertEqual(browser.headers['content-type'], 'text/html; charset=utf-8')To follow a link:browser.getLink('Edit').click()This gets a link by its text. To get a link by HTML id:browser.getLink(id='edit-link').click()To verify the current URL:self.assertEqual(portalURL + '/edit', browser.url)To set a form control value:browser.getControl('Age').value = u"30"This gets the control by its associated label. To get a control by its form
variable name:browser.getControl(name='age:int').value = u"30"See thezope.testbrowserdocumentation for more details on how to select
and manipulate various types of controls.To submit a form by clicking a button:browser.getControl('Save').click()Again, this uses the label to find the control. To use the form variable
name:browser.getControl(name='form.button.Save').click()To simulate HTTP BASIC authentication and remain logged in for all
requests:from plone.app.testing import TEST_USER_NAME, TEST_USER_PASSWORD

browser.addHeader('Authorization', 'Basic %s:%s' % (TEST_USER_NAME, TEST_USER_PASSWORD,))To simulate logging in via the login form:browser.open(portalURL + '/login_form')
browser.getControl(name='__ac_name').value = TEST_USER_NAME
browser.getControl(name='__ac_password').value = TEST_USER_PASSWORD
browser.getControl(name='submit').click()To simulate logging out:browser.open(portalURL + '/logout')Debugging tipsBy default, only HTTP error codes (e.g. 500 Server Side Error) are shown when
an error occurs on the server. To see more details, sethandleErrorsto
False:browser.handleErrors = FalseTo inspect the error log and obtain a full traceback of the latest entry:from Products.CMFCore.utils import getToolByName

errorLog = getToolByName(portal, 'error_log')
print errorLog.getLogEntries()[-1]['tb_text']To save the current response to an HTML file:open('/tmp/testbrowser.html', 'w').write(browser.contents)You can now open this file and use tools like Firebug to inspect the structure
of the page. You should remove the file afterwards.Comparison with ZopeTestCase/PloneTestCaseplone.testingandplone.app.testinghave in part evolved fromZopeTestCase, which ships with Zope 2 in theTestingpackage, andProducts.PloneTestCase, which ships with Plone and is used by Plone itself
as well as numerous add-on products.If you are familiar withZopeTestCaseandPloneTestCase, the concepts
of these package should be familiar to you. However, there are some important
differences to bear in mind.plone.testingandplone.app.testingare unburdened by the legacy
support thatZopeTestCaseandPloneTestCasehave to include. This
makes them smaller and easier to understand and maintain.Conversely,plone.testingonly works with Python 2.6 and Zope 2.12 and
later.plone.app.testingonly works with Plone 4 and later. If you need
to write tests that run against older versions of Plone, you’ll need to usePloneTestCase.ZopeTestCase/PloneTestCasewere written before layers were available
as a setup mechanism.plone.testingis very layer-oriented.PloneTestCaseprovides a base class, also calledPloneTestCase,
which you must use, as it performs setup and tear-down.plone.testingmoves shared state to layers and layer resources, and does not impose any
particular base class for tests. This does sometimes mean a little more
typing (e.g.self.layer['portal']vs.self.portal), but it makes
it much easier to control and reuse test fixtures. It also makes your
test code simpler and more explicit.ZopeTestCasehas aninstallProduct()function and a correspondinginstallPackage()function.plone.testinghas only aninstallProduct(), which can configure any kind of Zope 2 product (i.e.
packages in theProducts.*namespace, old-style products in a specialProductsfolder, or packages in any namespace that have had their ZCML
loaded and which include a<five:registerPackage />directive in their
configuration). Note that you must pass a full dotted name to this function,
even for “old-style” products in theProducts.*namespace, e.g.Products.LinguaPloneinstead ofLinguaPlone.On setup,PloneTestCasewill load Zope 2’s defaultsite.zcml. This
in turn will load all ZCML for all packages in theProducts.*namespace.plone.testingdoes not do this (and you are strongly encouraged from
doing it yourself), because it is easy to accidentally include packages in
your fixture that you didn’t intend to be there (and which can actually
change the fixture substantially). You should load your package’s ZCML
explicitly. See theplone.testingdocumentation for details.When usingPloneTestCase, any package that has been loaded ontosys.pathand which defines thez3c.autoinclude.plugin:ploneentry
point will be loaded viaz3c.autoinclude’s plugin mechanism. This loading
is explicitly disabled, for the same reasons that theProducts.*auto-
loading is. You should load your packages’ configuration explicitly.PloneTestCasesets up a basic fixture that has member folder enabled,
and in which the test user’s member folder is available asself.folder.
Theplone_workflowworkflow is also installed as the default.plone.app.testingtakes a more minimalist approach. To create a test
folder owned by the test user that is similar toself.folderin aPloneTestCase, you can do:import unittest2 as unittest
from plone.app.testing import TEST_USER_ID, setRoles
from plone.app.testing import PLONE_INTEGRATION_TESTING

class MyTest(unitest.TestCase):

    layer = PLONE_INTEGRATION_TESTING

    def setUp(self):
        self.portal = self.layer['portal']

        setRoles(self.portal, TEST_USER_ID, ['Manager'])
        self.portal.invokeFactory('Folder', 'test-folder')
        setRoles(self.portal, TEST_USER_ID, ['Member'])

        self.folder = self.portal['test-folder']You could of course do this type of setup in your own layer and expose it
as a resource instead.To usezope.testbrowserwithPloneTestCase, you should use itsFunctionalTestCaseas a base class, and then use the following pattern:from Products.Five.testbrowser import Browser
browser = Browser()The equivalent pattern inplone.app.testingis to use theFunctionalTestingtest lifecycle layer (see example above), and then
use:from plone.testing.z2 import Browser
browser = Browser(self.layer['app'])Also note that if you have made changes to the fixture prior to callingbrowser.open(), they willnotbe visible until you perform an
explicit commit. See thezope.testbrowserexamples above for details.Changelog7.0.2 (2024-01-19)Internal:Update configuration files.
[plone devs] (cfffba8c)7.0.1 (2023-04-15)Internal:Update configuration files.
[plone devs] (434550cc)7.0.0 (2022-12-02)Bug fixes:Final release for Plone 6.0.0. (#600)7.0.0b2 (2022-10-11)Bug fixes:Restore the previously used admin password for tests (“secret”) [davisagli] (#79)7.0.0b1 (2022-09-30)Bug fixes:Increase the test password length. [davisagli] (#78)7.0.0a3 (2022-04-28)New features:Load CMFFormController in Plone 5, be silent when this fails in Plone 6.
This restores compatibility with Plone 5.2 for now.
Note that thisplone.app.testingversion is only meant for Python 3.
[maurits] (#3467)7.0.0a2 (2022-04-04)Bug fixes:Add savepoint after creating the portal in PloneFixture.
Fixesissue 3467.
[pbauer] (#76)7.0.0a1 (2022-03-23)Breaking changes:Plone 6 only. (#75)New features:remove CMFFormController
[petschki] (#75)6.1.9 (2021-09-01)Bug fixes:Fixed test that failed for dexterity site root.
[jaroel, ale-rt] (#60)6.1.8 (2020-11-11)Bug fixes:Before trying to load the zcml of plone.app.folder, double check if it is a real package or an alias provided by plone.app.upgrade (#72)6.1.7 (2020-10-12)New features:Removed backwards compatibility code for old quickinstaller.
Current plone.app.testing is only for Plone 5.2+, so this code was no longer used.
See alsoPLIP 1775.
[maurits] (#1775)6.1.6 (2020-09-26)Bug fixes:Fixed test failure on Python 3 with Products.MailHost 4.10.
[maurits] (#3178)6.1.5 (2020-04-20)Bug fixes:Minor packaging updates. (#1)6.1.4 (2020-03-09)Bug fixes:Fix a test isolation issue that was preventing the MOCK_MAILHOST_FIXTURE to be used in multiple testcases [ale-rt] (#61)MockMailHostLayer configures the mail sender setting the appropriate registry records (Fixes #62) (#62)Fix tests when using zope.testrunner internals since its version 5.1.
[jensens] (#68)Do not load Products/ZCML of no longer existing Products.ResourceRegistries.
[jensens] (#69)6.1.3 (2019-02-16)Bug fixes:Make plone.app.folder a optional product for PloneFixture in py2 (#59)6.1.2 (2019-02-13)Bug fixes:Fixed the travis build checking the Python versions Plone actually supports.
Also fixed Python versions in setup.py (#57)6.1.1 (2018-11-05)Bug fixes:Fix the package manifest that was not including some files
[ale-rt]6.1.0 (2018-11-04)Breaking changes:Requireplone.testing >= 7.0.New features:Add support for Python 3.5 and 3.6.
[loechel, ale-rt, icemac, davisagli, pbauer]6.0.0 (2018-10-05)New features:Install and load zcml of CMFQuickInstallerTool only when importable.
[maurits]Load negotiator from plone.i18n (PTS removed).
[jensens, ksuess]Add copy of bbb.PloneTestCase.
For Plone 5.2 the bbb.PloneTestCase will uses Dexterity instead of Archetypes.
Adding bbb_at.PloneTestCase for them to use allows to keep the AT tests working.
Seehttps://github.com/plone/plone.app.testing/pull/51[pbauer]Bug fixes:Amended the doctests to work with automatically layer port picking from plone.testing.
[Rotonen]5.0.8 (2017-10-25)Bug fixes:Load Products.PageTemplates ZCML.  [tschorr]5.0.7 (2017-07-03)Bug fixes:Remove deprecated __of__ calls on BrowserViews
[MrTango]Remove unittest2 dependency
[kakshay21]5.0.6 (2016-12-19)Bug fixes:No longer try to loadProducts.SecureMailHostand its zcml.
This is not shipped with Plone 5.0 or higher.  [maurits]5.0.5 (2016-11-19)Bug fixes:Do not use install Products.PasswordResetTool in the PloneFixture if it isn’t available.
[thet]5.0.4 (2016-09-23)New features:Use get_installer instead of portal_quickinstaller when available, for
Plone 5.1 and higher.  [maurits]In PloneSandboxLayer make profile upgrade versions persistent.  This
way installed profile versions get reset in teardown.  [maurits]5.0.3 (2016-09-07)Bug fixes:Load Products.CMFFormController in tests.  It is still used by core
Plone, also without Archetypes.  This makes the CMFFormController
tests pass.  [maurits]5.0.2 (2016-06-07)Fixes:Do not use install Products.SecureMailHost in the PloneFixture if it isn’t available
[vangheem]5.0.1 (2016-02-26)Fixes:Replace deprecatedzope.site.hooksimport withzope.component.hooks.
[thet]5.0.0 (2016-02-20)New:Add a MOCK_MAILHOST_FIXTURE fixture that integration and functional tests layers can depend on.
This allows to easily check how mails are sent from Plone.
[gforcada]Fixes:Fixlayers.rstdoctest to be compatible with older and newer zope.testrunner layer ordering.
[thet]Depend onzope.testrunnerand fix deprecated usage ofzope.testing.testrunner.
[thet]Cleanup code, flake8, sort imports, etc.
[gforcada]Fix RAM cache error with bbb.PloneTestCase.
[ebrehault]5.0b6 (2015-08-22)No need for unittest2.
[gforcada]5.0b5 (2015-07-18)Do not install CMFDefault.
[tomgross]Document PloneWithPackageLayer.
[gotcha]5.0b4 (2015-05-04)Do not install CMFFormController.
[timo]Do not install CMFDefault
[tomgross]5.0b3 (2015-03-26)Remove PloneLanguageTool from PloneFixture.
[timo]5.0b2 (2015-03-13)remove test of applying an extension profile, we don’t have a good one to
test now.
[davidagli]fix test, plone.app.theming does not get recorded as installed .
[davisagli]fix:Products.CMFPloneneeds thegopipindex fromplone.app.folder. So latter has to be initialized before CMFPlones
profile is applied (which installs the index to catalog). At the moment
CMFPlone therefore registers the index itself, but plone.app.folder
registers it too, which resulted in plone/Products.CMFPlone#313
“GopipIndex registered twice” In tests the registration does not succeed,
because plone.app.folder was never initialized as z2 products. In order to
remove the misleading regisatration from CMFPlone we must take care that the
index is available, which is achieved with this change. Also minor pep8
optimizations in the file touched.
[jensens]create memberfolder, if it is not there for testing.
[tomgross]5.0b1 (2014-10-23)Allow applyProfile to skip steps and all other options supported by
runAllImportStepsFromProfile of portal_setup-tool.
[pbauer, tomgross]5.0a2 (2014-04-19)Install Products.DateRecurringIndex for the PLONE_FIXTURE Layer.
[thet]5.0a1 (2014-02-22)Add ‘ROBOT_TEST_LEVEL’ to interfaces, so other packages can import it. This
makes things easier if we decide to change the value.
[timo]Replace deprecated test assert statements.
[timo]plonetheme.classic no longer ships with Plone, don’t use it for
testing.
[esteele]Clean up the zodbDB and configurationContext resources if there
is an error during the PloneSandboxLayer setUp.
[davisagli]Make PLONE_FIXTURE not install a content type system.
Packages that need content types to run their tests should
pick the appropriate fixture from plone.app.contenttypes
or Products.ATContentTypes.
[davisagli]Pin [robot] extra torobotsuite>=1.4.0.
[saily]Fix wrong spelling ofreinstallProductsmethod in quickInstallProduct.
[saily]Sync bbb PloneTestCase class with original one.
[tomgross]4.2.2 (2013-02-09)Add [robot] extras for requiring dependnecies for Robot Framework
tests with Selenium2Library
[datakurre]Install PythonScripts as zope product
[mikejmets]4.2.1 (2012-12-15)Allow testing with non standard port. Allows running multiple test suites
in parallel.
[do3cc]Documentation updates.
[moo]4.2 (2012-04-15)Branch as 4.2 as the plone.app.collection addition breaks backwards
compatibility.
[esteele]Fixed spurious failure in our own tests by using a longer timeout.
[maurits]plone.app.collection added to PloneFixture.
[timo]4.0.2 (2011-08-31)Load ZCML before installing Zope products inPloneWithPackageLayer;
it enables package registration.
[gotcha]4.0.1 (2011-07-14)Addadditional_z2_productsparameter toPloneWithPackageLayerhelper class to install additional Zope 2 products.
[jfroche]4.0 - 2011-05-134.0 Final release.
[esteele]Add MANIFEST.in.
[WouterVH]4.0a6 - 2011-04-06Added helper functions for selenium layer. (Copied from SeleniumTestCase
within Products.CMFPlone/Products/CMFPlone/tests/selenium/base.py)
[emanlove]Rework layer setup of SeleniumLayer so that z2.ZSERVER_FIXTURE is a
default_base.
[esteele]Convert the passed-in selenium webdriver name to lowercase before doing a
module lookup.
[esteele]Moved selenium start up and tear down to testSetUp and testTearDown,
respectively.  This was done to help further isolate individual tests.
For example, logging in under one test would require either logging out
or shutting down the browser, which is what the selenium_layer will now
do under testTearDown, in order to have a “clean” state within the next
test.
[emanlove]Corrected module path for the various selenium webdrivers using
selenium 2.0b2.
[emanlove]4.0a5 - 2011-03-02Use the newplone.testing.securitymodule to ensure isolation of
security checkers when setting up and tearing down layers based on thePloneSandboxLayerhelper base class. This would cause problems when
running multiple test suites in the same test run, in particular if one of
those suites were setting up ZCML that usedfive.grok.
[optilude]4.0a4 - 2011-01-11Automatically tear down PAS registrations via snapshotting when usingPloneSandboxLayer. It’s too difficult to do this manually when you
consider that plugins may be registered in ZCML via transitive dependencies.
There should be no backwards compatibility concern - usingtearDownMultiPlugin()is still supported, and it’s generally safe to
call it once.
[optilude]Try to make suretearDownMultiPlugin()and the generic PAS plugin
cleanup handler do not interfere with the cleanup handler from the PAS
ZCML directive.
[optilude]Do not installProducts.kupuorProducts.CMFPlacefulWorkflow.
[elro]Depend onProducts.CMFPloneinstead ofPlone.
[elro]4.0a3 - 2010-12-14Allow top-level import of PloneTestLifecycle.
[stefan]Added a warning not to use ‘default’ Firefox profile for selenium tests.
[zupo]Fixed distribution dependency declarations.
[hannosch]Correct license to GPL version 2 only.
[hannosch]Make some module imports helper methods on the already policy-heavy
helper class per optilude’s suggestion.
[rossp]Add a layer and test case for running selenium tests.
[rossp]Give the default test user differing user id and login name. This helps reveal
problems with userid vs login name errors, an overly common error.
[wichert]1.0a2 - 2010-09-05Make sure plone.app.imaging is installed properly during layer setup.
[optilude]1.0a1 - 2010-08-01Initial release