Skip to content

Commit

Permalink
set up functional test using a testbrowser
Browse files Browse the repository at this point in the history
  • Loading branch information
witsch committed Jan 15, 2009
1 parent c9c6993 commit 3f903da
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 5 deletions.
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
extras_require = dict(
test = [
'zope.testing',
'zope.app.publisher',
'zope.app.securitypolicy',
'zope.testbrowser',
],
),
entry_points = '',
Expand Down
6 changes: 6 additions & 0 deletions src/zope/globalrequest/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ Let's just check the interfaces for now:
>>> IGlobalRequest
<InterfaceClass zope.globalrequest.interfaces.IGlobalRequest>

>>> from zope.testbrowser.testing import Browser
>>> browser = Browser()
>>> browser.open('http://localhost/')
>>> browser.isHtml
True

28 changes: 28 additions & 0 deletions src/zope/globalrequest/ftesting.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
i18n_domain="zope"
package="zope.globalrequest">

<!-- This file is the equivalent of site.zcml and it is -->
<!-- used for functional testing setup -->

<include package="zope.app.zcmlfiles" />
<include package="zope.app.authentication" />

<unauthenticatedPrincipal
id="zope.anybody"
title="Unauthenticated User" />

<include package="zope.app.securitypolicy" file="meta.zcml"/>

<securityPolicy
component="zope.securitypolicy.zopepolicy.ZopeSecurityPolicy" />

<role id="zope.Anonymous" title="Everybody"
description="All users have this role implicitly" />

<grant permission="zope.View"
role="zope.Anonymous" />

</configure>
17 changes: 12 additions & 5 deletions src/zope/globalrequest/tests.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
from unittest import TestSuite
from zope.testing.doctest import DocFileSuite
from zope.testing import doctest
from zope.testing.cleanup import cleanUp
from zope.app.testing import functional
from os.path import join, abspath, dirname


def tearDown(test):
cleanUp()

testLayer = functional.ZCMLLayer(
join(abspath(dirname(__file__)), 'ftesting.zcml'),
__name__, 'TestBrowserLayer', allow_teardown=True)

def test_suite():
return TestSuite([
DocFileSuite('README.txt', package='zope.globalrequest',
tearDown=tearDown)
])
flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
readme = functional.FunctionalDocFileSuite('README.txt',
package='zope.globalrequest', optionflags=flags, tearDown=tearDown)
readme.layer = testLayer
return TestSuite((readme,))

0 comments on commit 3f903da

Please sign in to comment.