Skip to content
This repository has been archived by the owner on Apr 9, 2019. It is now read-only.

Commit

Permalink
Use plone.testing for functional test layer support.
Browse files Browse the repository at this point in the history
  • Loading branch information
hannosch committed May 19, 2012
1 parent f4d40c6 commit c665d7d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
3 changes: 3 additions & 0 deletions docs/HISTORY.txt
Expand Up @@ -4,6 +4,9 @@ Changelog
0.8 - unreleased
----------------

* Use plone.testing for functional test layer support.
[hannosch]

* Use ViewPageTemplateFile from zope.browserpage.
[hannosch]

Expand Down
35 changes: 24 additions & 11 deletions plone/z3cform/tests.py
@@ -1,20 +1,19 @@
import os
import doctest
import unittest

from plone.testing import Layer, z2, zca
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from zope import component
from zope import interface
from zope.component import testing
from zope.app.testing.functional import ZCMLLayer
import zope.traversing.adapters
import zope.traversing.namespace
import zope.publisher.interfaces.browser
import z3c.form.testing
from zope.configuration import xmlconfig

import plone.z3cform.templates

from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile


def create_eventlog(event=interface.Interface):
value = []
Expand Down Expand Up @@ -60,23 +59,37 @@ def setup_defaults():
(None, None, None, None, None, None),
z3c.form.interfaces.IErrorViewSnippet)

testing_zcml_path = os.path.join(os.path.dirname(__file__), 'testing.zcml')
testing_zcml_layer = ZCMLLayer(
testing_zcml_path, 'plone.z3cform', 'testing_zcml_layer')

class P3FLayer(Layer):
defaultBases = (z2.STARTUP, )

def setUp(self):
self['configurationContext'] = context = \
zca.stackConfigurationContext(self.get('configurationContext'))
import plone.z3cform
xmlconfig.file('testing.zcml', plone.z3cform, context=context)

def tearDown(self):
del self['configurationContext']


P3F_FIXTURE = P3FLayer()
FUNCTIONAL_TESTING = z2.FunctionalTesting(bases=(P3F_FIXTURE, ),
name="plone.z3cform:Functional")


def test_suite():
layout_txt = doctest.DocFileSuite('layout.txt')
layout_txt.layer = testing_zcml_layer
layout_txt.layer = FUNCTIONAL_TESTING

inputs_txt = doctest.DocFileSuite('inputs.txt')
inputs_txt.layer = testing_zcml_layer
inputs_txt.layer = FUNCTIONAL_TESTING

fieldsets_txt = doctest.DocFileSuite('fieldsets/README.txt')
fieldsets_txt.layer = testing_zcml_layer
fieldsets_txt.layer = FUNCTIONAL_TESTING

traversal_txt = doctest.DocFileSuite('traversal.txt')
traversal_txt.layer = testing_zcml_layer
traversal_txt.layer = FUNCTIONAL_TESTING

return unittest.TestSuite([
layout_txt, inputs_txt, fieldsets_txt, traversal_txt,
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Expand Up @@ -40,8 +40,8 @@ def description():
'zope.component',
'collective.monkeypatcher',
],
extras_require = {
extras_require={
'test': ['lxml',
'zope.app.testing']
'plone.testing']
}
)

0 comments on commit c665d7d

Please sign in to comment.