I've been trying to add compatibility with Plone 5 in some of our add-ons and I found a pattern that I want to avoid: seem that I have to manually install default content types on test fixture like this:
...
PLONE_VERSION = api.env.plone_version()
class Fixture(PloneSandboxLayer):
defaultBases = (PLONE_FIXTURE,)
def setUpZope(self, app, configurationContext):
if PLONE_VERSION >= '5.0':
import plone.app.contenttypes
self.loadZCML(package=plone.app.contenttypes)
...
def setUpPloneSite(self, portal):
if PLONE_VERSION >= '5.0':
self.applyProfile(portal, 'plone.app.contenttypes:default')
...
FIXTURE = Fixture()
...
Is there any way to avoid this?
As far as I remember it is enough to depend on PLONE_APP_CONTENTTYPES_FIXTURE. Something like this (untested):
try:
from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE
except ImportError:
PLONE_APP_CONTENTTYPES_FIXTURE = None
class Fixture(PloneSandboxLayer):
if PLONE_VERSION >= '5.0':
defaultBases = (PLONE_APP_CONTENTTYPES_FIXTURE,)
else:
defaultBases = (PLONE_FIXTURE,)