[Zope3-checkins] CVS: Zope3/src/zope/app/publisher/browser/tests -
test_directives.py:1.21.2.1
test_globalbrowsermenuservicedirectives.py:1.6.2.1
test_icondirective.py:1.8.2.1
Philipp von Weitershausen
philikon at philikon.de
Wed Aug 6 11:28:31 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/publisher/browser/tests
In directory cvs.zope.org:/tmp/cvs-serv14946/publisher/browser/tests
Modified Files:
Tag: zcml-interface-field-branch
test_directives.py test_globalbrowsermenuservicedirectives.py
test_icondirective.py
Log Message:
Fix up tests to use the ConfigurationMachine from zope.app.configure which
is service-aware.
=== Zope3/src/zope/app/publisher/browser/tests/test_directives.py 1.21 => 1.21.2.1 ===
--- Zope3/src/zope/app/publisher/browser/tests/test_directives.py:1.21 Sun Aug 3 13:50:24 2003
+++ Zope3/src/zope/app/publisher/browser/tests/test_directives.py Wed Aug 6 10:27:56 2003
@@ -11,43 +11,41 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
+"""
+$Id$
+"""
import os
import unittest
-from cStringIO import StringIO
from zope.interface import Interface, implements
-from zope.configuration.xmlconfig import xmlconfig, XMLConfig
+from zope.configuration import xmlconfig
from zope.configuration.exceptions import ConfigurationError
from zope.component.tests.views import IC, V1, VZMI
from zope.component import getView, queryView, queryResource
from zope.component import getDefaultViewName, getResource
-from zope.app.services.servicenames import Permissions
-from zope.app.tests.placelesssetup import PlacelessSetup
+from zope.component.service import serviceManager
from zope.security.proxy import ProxyFactory
from zope.proxy import removeAllProxies
-import zope.configuration
from zope.app.publisher.browser.globalbrowsermenuservice import \
- globalBrowserMenuService
+ globalBrowserMenuService
from zope.component.tests.request import Request
from zope.publisher.browser import TestRequest
-
-from zope.publisher.interfaces.browser import IBrowserPresentation
-
-from zope.app.publisher.browser.i18nfileresource import I18nFileResource
+from zope.publisher.interfaces.browser import IBrowserPresentation, \
+ IBrowserPublisher
import zope.app.publisher.browser
-from zope.component.service import serviceManager
-from zope.app.interfaces.security import IPermissionService
-from zope.app.security.registries.permissionregistry import permissionRegistry
+import zope.app.configuration
+import zope.app.component.service
-from zope.component.service import serviceManager
-from zope.app.security.registries.permissionregistry import permissionRegistry
from zope.app.interfaces.security import IPermissionService
+from zope.app.security.registries.permissionregistry import permissionRegistry
-from zope.publisher.interfaces.browser import IBrowserPublisher
+from zope.app.services.servicenames import Permissions
+from zope.app.tests.placelesssetup import PlacelessSetup
+from zope.app.publisher.browser.i18nfileresource import I18nFileResource
tests_path = os.path.join(
os.path.split(zope.app.publisher.browser.__file__)[0],
@@ -97,7 +95,7 @@
def setUp(self):
PlacelessSetup.setUp(self)
- XMLConfig('meta.zcml', zope.app.publisher.browser)()
+ self._config()
from zope.component.adapter import provideAdapter
from zope.app.traversing.adapters import DefaultTraversable
@@ -105,11 +103,19 @@
provideAdapter(None, ITraversable, DefaultTraversable)
+ def _config(self):
+ sm = zope.app.component.service.globalServiceManager()
+ context = zope.app.configuration.ConfigurationMachine(sm)
+ xmlconfig.registerCommonDirectives(context)
+ xmlconfig.file('meta.zcml', package=zope.app.publisher.browser,
+ context=context)
+ self._context = context
+
def testPage(self):
self.assertEqual(queryView(ob, 'test', request),
None)
- xmlconfig(StringIO(template % (
+ xmlconfig.string(template % (
"""
<browser:page name="test"
class="zope.component.tests.views.V1"
@@ -118,7 +124,8 @@
attribute="index"
/>
"""
- )))
+ ),
+ context=self._context)
v = queryView(ob, 'test', request)
self.assert_(issubclass(v.__class__, V1))
@@ -127,9 +134,8 @@
self.assertEqual(queryView(ob, 'test', request),
None)
testusage = os.path.join(tests_path, 'testusage.pt')
-
- xmlconfig(StringIO(template % (
+ xmlconfig.string(template % (
"""
<browser:menu id="test_menu" title="Test menu" usage="objectview"/>
<browser:page name="test"
@@ -141,7 +147,8 @@
title="Test View"
/>
""" % testusage
- )))
+ ),
+ context=self._context)
menuItem = globalBrowserMenuService.getFirstMenuItem('test_menu', ob, TestRequest())
self.assertEqual(menuItem["title"], "Test View")
@@ -153,9 +160,8 @@
self.assertEqual(queryView(ob, 'test', request),
None)
testusage = os.path.join(tests_path, 'testusage.pt')
-
- xmlconfig(StringIO(template % (
+ xmlconfig.string(template % (
"""
<browser:page name="test"
class="zope.component.tests.views.V1"
@@ -165,7 +171,8 @@
usage="objectview"
/>
""" % testusage
- )))
+ ),
+ context=self._context)
v = queryView(ob, 'test', request)
self.assertEqual(v(), "objectview\n")
@@ -176,7 +183,7 @@
testusage = os.path.join(tests_path, 'testusage.pt')
- xmlconfig(StringIO(template % (
+ xmlconfig.string(template % (
"""
<browser:menu id="test_menu" title="Test menu" usage="overridden"/>
<browser:page name="test"
@@ -189,7 +196,8 @@
usage="objectview"
/>
""" % testusage
- )))
+ ),
+ context=self._context)
menuItem = globalBrowserMenuService.getFirstMenuItem('test_menu', ob, TestRequest())
self.assertEqual(menuItem["title"], "Test View")
@@ -203,7 +211,7 @@
testusage = os.path.join(tests_path, 'testusage.pt')
- xmlconfig(StringIO(template % (
+ xmlconfig.string(template % (
"""
<browser:menu id="test_menu" title="Test menu" usage="objectview"/>
<browser:page name="test"
@@ -214,7 +222,8 @@
title="Test View"
/>
""" % testusage
- )))
+ ),
+ context=self._context)
menuItem = globalBrowserMenuService.getFirstMenuItem('test_menu', ob, TestRequest())
self.assertEqual(menuItem["title"], "Test View")
@@ -228,7 +237,7 @@
testusage = os.path.join(tests_path, 'testusage.pt')
- xmlconfig(StringIO(template % (
+ xmlconfig.string(template % (
"""
<browser:page name="test"
for="zope.component.tests.views.IC"
@@ -237,7 +246,8 @@
usage="objectview"
/>
""" % testusage
- )))
+ ),
+ context=self._context)
v = queryView(ob, 'test', request)
self.assertEqual(v(), "objectview\n")
@@ -246,9 +256,8 @@
self.assertEqual(queryView(ob, 'test', request),
None)
testusage = os.path.join(tests_path, 'testusage.pt')
-
- xmlconfig(StringIO(template % (
+ xmlconfig.string(template % (
"""
<browser:menu id="test_menu" title="Test menu" usage="overridden"/>
<browser:page name="test"
@@ -260,7 +269,8 @@
usage="objectview"
/>
""" % testusage
- )))
+ ),
+ context=self._context)
menuItem = globalBrowserMenuService.getFirstMenuItem('test_menu', ob, TestRequest())
self.assertEqual(menuItem["title"], "Test View")
@@ -274,7 +284,7 @@
testusage = os.path.join(tests_path, 'testusage.pt')
- xmlconfig(StringIO(template % (
+ xmlconfig.string(template % (
"""
<browser:menu id="test_menu" title="Test menu" usage="objectview"/>
<browser:pages for="zope.component.tests.views.IC"
@@ -286,7 +296,8 @@
/>
</browser:pages>
""" % testusage
- )))
+ ),
+ context=self._context)
menuItem = globalBrowserMenuService.getFirstMenuItem('test_menu', ob, TestRequest())
self.assertEqual(menuItem["title"], "Test View")
@@ -300,7 +311,7 @@
testusage = os.path.join(tests_path, 'testusage.pt')
- xmlconfig(StringIO(template % (
+ xmlconfig.string(template % (
"""
<browser:menu id="test_menu" title="Test menu" usage="objectview"/>
<browser:pages for="zope.component.tests.views.IC"
@@ -313,7 +324,8 @@
/>
</browser:pages>
""" % testusage
- )))
+ ),
+ context=self._context)
menuItem = globalBrowserMenuService.getFirstMenuItem('test_menu', ob, TestRequest())
self.assertEqual(menuItem["title"], "Test View")
@@ -325,22 +337,21 @@
self.assertEqual(queryView(ob, 'test', request,
None), None)
- xmlconfig(StringIO(template % (
+ xmlconfig.string(template % (
"""
<browser:defaultView name="test"
for="zope.component.tests.views.IC" />
"""
- )))
-
- self.assertEqual(getDefaultViewName(ob, request
- ), 'test')
+ ),
+ context=self._context)
+ self.assertEqual(getDefaultViewName(ob, request), 'test')
def testSkinPage(self):
self.assertEqual(queryView(ob, 'test', request,
None), None)
- xmlconfig(StringIO(template % (
+ xmlconfig.string(template % (
"""
<browser:skin name="zmi" layers="zmi default" />
<browser:page name="test"
@@ -357,7 +368,8 @@
attribute="index"
/>
"""
- )))
+ ),
+ context=self._context)
v = queryView(ob, 'test', request)
self.assert_(issubclass(v.__class__, V1))
@@ -372,14 +384,15 @@
path1 = os.path.join(tests_path, 'test.pt')
path2 = os.path.join(tests_path, 'test2.pt')
- xmlconfig(StringIO(template % (
+ xmlconfig.string(template % (
"""
<browser:i18n-resource name="test" defaultLanguage="fr">
<browser:translation language="en" file="%s" />
<browser:translation language="fr" file="%s" />
</browser:i18n-resource>
""" % (path1, path2)
- )))
+ ),
+ context=self._context)
v = getResource(ob, 'test', request)
self.assertEqual(
@@ -389,29 +402,31 @@
self.assertEqual(v._testData('fr'), open(path2, 'rb').read())
# translation must be provided for the default language
- config = StringIO(template % (
+ config = template % (
"""
<browser:i18n-resource name="test" defaultLanguage="fr">
<browser:translation language="en" file="%s" />
<browser:translation language="lt" file="%s" />
</browser:i18n-resource>
""" % (path1, path2)
- ))
- self.assertRaises(ConfigurationError, xmlconfig, config)
+ )
+ self.assertRaises(ConfigurationError, xmlconfig.string, config,
+ context=self._context)
# files and images can't be mixed
- config = StringIO(template % (
+ config = template % (
"""
<browser:i18n-resource name="test" defaultLanguage="fr">
<browser:translation language="en" file="%s" />
<browser:translation language="fr" image="%s" />
</browser:i18n-resource>
""" % (path1, path2)
- ))
- self.assertRaises(ConfigurationError, xmlconfig, config)
+ )
+ self.assertRaises(ConfigurationError, xmlconfig.string, config,
+ context=self._context)
def testInterfaceProtectedPage(self):
- xmlconfig(StringIO(template %
+ xmlconfig.string(template %
"""
<browser:page name="test"
class="zope.component.tests.views.V1"
@@ -420,8 +435,7 @@
permission="zope.Public"
allowed_interface="zope.component.tests.views.IV"
/>
- """
- ))
+ """, context=self._context)
v = getView(ob, 'test', request)
v = ProxyFactory(v)
@@ -429,7 +443,7 @@
self.assertRaises(Exception, getattr, v, 'action')
def testAttributeProtectedPage(self):
- xmlconfig(StringIO(template %
+ xmlconfig.string(template %
"""
<browser:page name="test"
class="zope.component.tests.views.V1"
@@ -438,8 +452,7 @@
permission="zope.Public"
allowed_attributes="action"
/>
- """
- ))
+ """, context=self._context)
v = getView(ob, 'test', request)
v = ProxyFactory(v)
@@ -447,7 +460,7 @@
self.assertRaises(Exception, getattr, v, 'index')
def testInterfaceAndAttributeProtectedPage(self):
- xmlconfig(StringIO(template %
+ xmlconfig.string(template %
"""
<browser:page name="test"
class="zope.component.tests.views.V1"
@@ -457,15 +470,14 @@
allowed_attributes="action"
allowed_interface="zope.component.tests.views.IV"
/>
- """
- ))
+ """, context=self._context)
v = getView(ob, 'test', request)
self.assertEqual(v.index(), 'V1 here')
self.assertEqual(v.action(), 'done')
def testDuplicatedInterfaceAndAttributeProtectedPage(self):
- xmlconfig(StringIO(template %
+ xmlconfig.string(template %
"""
<browser:page name="test"
class="zope.component.tests.views.V1"
@@ -475,15 +487,14 @@
allowed_attributes="action index"
allowed_interface="zope.component.tests.views.IV"
/>
- """
- ))
+ """, context=self._context)
v = getView(ob, 'test', request)
self.assertEqual(v.index(), 'V1 here')
self.assertEqual(v.action(), 'done')
def test_class_w_implements(self):
- xmlconfig(StringIO(template %
+ xmlconfig.string(template %
"""
<browser:page
name="test"
@@ -493,34 +504,27 @@
attribute="index"
permission="zope.Public"
/>
- """
- ))
+ """, context=self._context)
v = getView(ob, 'test', request)
self.assertEqual(v.index(), v)
self.assert_(IBrowserPublisher.isImplementedBy(v))
def testIncompleteProtectedPageNoPermission(self):
- self.assertRaises(
- ConfigurationError,
- xmlconfig,
- StringIO(template %
- """
- <browser:page name="test"
- class="zope.component.tests.views.V1"
- for="zope.component.tests.views.IC"
- attribute="index"
- allowed_attributes="action index"
- />
- """
- ))
-
+ self.assertRaises(ConfigurationError, xmlconfig.string,
+ template % """
+ <browser:page name="test"
+ class="zope.component.tests.views.V1"
+ for="zope.component.tests.views.IC"
+ attribute="index"
+ allowed_attributes="action index"
+ />""", context=self._context)
def testPageViews(self):
self.assertEqual(queryView(ob, 'test', request), None)
test3 = os.path.join(tests_path, 'test3.pt')
- xmlconfig(StringIO(template %
+ xmlconfig.string(template %
"""
<browser:pages
class="zope.component.tests.views.V1"
@@ -532,8 +536,7 @@
<browser:page name="action.html" attribute="action" />
<browser:page name="test.html" template="%s" />
</browser:pages>
- """ % test3
- ))
+ """ % test3, context=self._context)
v = getView(ob, 'index.html', request)
self.assertEqual(v(), 'V1 here')
@@ -545,7 +548,7 @@
def testNamedViewPageViewsCustomTraversr(self):
self.assertEqual(queryView(ob, 'test', request), None)
- xmlconfig(StringIO(template %
+ xmlconfig.string(template %
"""
<browser:view
name="test"
@@ -557,8 +560,7 @@
<browser:page name="index.html" attribute="index" />
<browser:page name="action.html" attribute="action" />
</browser:view>
- """
- ))
+ """, context=self._context)
view = getView(ob, 'test', request)
view = removeAllProxies(view)
@@ -576,7 +578,7 @@
def testNamedViewNoPagesForCallable(self):
self.assertEqual(queryView(ob, 'test', request), None)
- xmlconfig(StringIO(template %
+ xmlconfig.string(template %
"""
<browser:view
name="test"
@@ -584,8 +586,7 @@
for="zope.component.tests.views.IC"
permission="zope.Public"
/>
- """
- ))
+ """, context=self._context)
view = getView(ob, 'test', request)
view = removeAllProxies(view)
@@ -594,7 +595,7 @@
def testNamedViewNoPagesForNonCallable(self):
self.assertEqual(queryView(ob, 'test', request), None)
- xmlconfig(StringIO(template %
+ xmlconfig.string(template %
"""
<browser:view
name="test"
@@ -602,8 +603,7 @@
for="zope.component.tests.views.IC"
permission="zope.Public"
/>
- """
- ))
+ """, context=self._context)
view = getView(ob, 'test', request)
view = removeAllProxies(view)
@@ -613,7 +613,7 @@
self.assertEqual(queryView(ob, 'test', request), None)
test3 = os.path.join(tests_path, 'test3.pt')
- xmlconfig(StringIO(template %
+ xmlconfig.string(template %
"""
<browser:view
name="test"
@@ -626,8 +626,7 @@
<browser:page name="action.html" attribute="action" />
<browser:page name="test.html" template="%s" />
</browser:view>
- """ % test3
- ))
+ """ % test3, context=self._context)
view = getView(ob, 'test', request)
view = removeAllProxies(view)
@@ -648,7 +647,7 @@
self.assertEqual(queryView(ob, 'test', request), None)
test3 = os.path.join(tests_path, 'test3.pt')
- xmlconfig(StringIO(template %
+ xmlconfig.string(template %
"""
<browser:view
name="test"
@@ -662,8 +661,7 @@
<browser:page name="action.html" attribute="action" />
<browser:page name="test.html" template="%s" />
</browser:view>
- """ % test3
- ))
+ """ % test3, context=self._context)
view = getView(ob, 'test', request)
view = removeAllProxies(view)
@@ -690,7 +688,7 @@
self.assertEqual(queryView(ob, 'test', request),
None)
- xmlconfig(StringIO(template %
+ xmlconfig.string(template %
"""
<directives namespace="http://namespaces.zope.org/zope">
<directive name="permission"
@@ -710,8 +708,7 @@
<browser:page name="index.html" attribute="index" />
<browser:page name="action.html" attribute="action" />
</browser:pages>
- """
- ))
+ """, context=self._context)
v = getView(ob, 'index.html', request)
v = ProxyFactory(v)
@@ -724,7 +721,7 @@
self.assertEqual(queryView(ob, 'test', request),
None)
- xmlconfig(StringIO(template %
+ xmlconfig.string(template %
"""
<directives namespace="http://namespaces.zope.org/zope">
<directive name="permission"
@@ -745,8 +742,7 @@
<browser:page name="index.html" attribute="index" />
<browser:page name="action.html" attribute="action" />
</browser:view>
- """
- ))
+ """, context=self._context)
# XXX this seems to be no longer needed
# Need to "log someone in" to turn on checks
@@ -762,7 +758,7 @@
def testSkinnedPageView(self):
self.assertEqual(queryView(ob, 'test', request), None)
- xmlconfig(StringIO(template %
+ xmlconfig.string(template %
"""
<browser:skin name="skinny" layers="layer default" />
<browser:pages
@@ -782,8 +778,7 @@
<browser:page name="index.html" attribute="action" />
</browser:pages>
- """
- ))
+ """, context=self._context)
v = getView(ob, 'index.html', request)
self.assertEqual(v(), 'V1 here')
@@ -797,14 +792,13 @@
self.assertEqual(queryResource(ob, 'test', request),
None)
- xmlconfig(StringIO(template %
+ xmlconfig.string(template %
"""
<browser:resource
name="index.html"
file="%s"
/>
- """ % path
- ))
+ """ % path, context=self._context)
r = getResource(ob, 'index.html', request)
@@ -817,7 +811,6 @@
r = removeAllProxies(r)
self.assertEqual(r._testData(), open(path, 'rb').read())
-
def testSkinResource(self):
self.assertEqual(
queryResource(ob, 'test', request, None),
@@ -825,13 +818,14 @@
path = os.path.join(tests_path, 'test.pt')
- xmlconfig(StringIO(template % (
+ xmlconfig.string(template % (
"""
<browser:skin name="zmi" layers="zmi default" />
<browser:resource name="test" file="%s"
layer="zmi" />
""" % path
- )))
+ ),
+ context=self._context)
self.assertEqual(queryResource(ob, 'test', request), None)
@@ -845,15 +839,14 @@
self.assertEqual(queryView(ob, 'index.html', request),
None)
- xmlconfig(StringIO(template %
+ xmlconfig.string(template %
"""
<browser:page
name="index.html"
template="%s"
permission="zope.Public"
for="zope.component.tests.views.IC" />
- """ % path
- ))
+ """ % path, context=self._context)
v = getView(ob, 'index.html', request)
self.assertEqual(v().strip(), '<html><body><p>test</p></body></html>')
@@ -864,16 +857,15 @@
self.assertEqual(queryView(ob, 'index.html', request),
None)
- xmlconfig(StringIO(template %
+ xmlconfig.string(template %
"""
<browser:page
name="index.html"
template="%s"
permission="zope.Public"
- class="zope.app.publisher.browser.tests.templateclass.templateclass"
+ class="zope.app.publisher.browser.tests.templateclass.templateclass"
for="zope.component.tests.views.IC" />
- """ % path
- ))
+ """ % path, context=self._context)
v = getView(ob, 'index.html', request)
self.assertEqual(v().strip(), '<html><body><p>42</p></body></html>')
@@ -888,7 +880,7 @@
self.assertEqual(queryView(ob, 'test', request),
None)
- xmlconfig(StringIO(template %
+ xmlconfig.string(template %
"""
<directives namespace="http://namespaces.zope.org/zope">
<directive name="permission"
@@ -904,18 +896,16 @@
template="%s"
permission="zope.TestPermission"
for="zope.component.tests.views.IC" />
- """ % path
- ))
+ """ % path, context=self._context)
- xmlconfig(StringIO(template %
+ xmlconfig.string(template %
"""
<browser:page
name="index.html"
template="%s"
permission="zope.Public"
for="zope.component.tests.views.IC" />
- """ % path
- ))
+ """ % path, context=self._context)
# XXX This seems to be no longer needed
# Need to "log someone in" to turn on checks
@@ -933,37 +923,29 @@
def testtemplateNoName(self):
path = os.path.join(tests_path, 'test.pt')
- self.assertRaises(
- ConfigurationError,
- xmlconfig,
- StringIO(template %
- """
- <browser:page
- template="%s"
- for="zope.component.tests.views.IC"
- />
- """ % path
- ))
+ self.assertRaises(ConfigurationError, xmlconfig.string,
+ template %
+ """
+ <browser:page
+ template="%s"
+ for="zope.component.tests.views.IC"
+ />
+ """ % path, context=self._context)
def testtemplateAndPage(self):
path = os.path.join(tests_path, 'test.pt')
- self.assertRaises(
- ConfigurationError,
- xmlconfig,
- StringIO(template %
- """
- <browser:view
- name="index.html"
- template="%s"
- for="zope.component.tests.views.IC"
- permission="zope.Public"
- >
- <browser:page name="foo.html" attribute="index" />
- </browser:view>
- """ % path
- ))
-
-
+ self.assertRaises(ConfigurationError, xmlconfig.string,
+ template %
+ """
+ <browser:view
+ name="index.html"
+ template="%s"
+ for="zope.component.tests.views.IC"
+ permission="zope.Public"
+ >
+ <browser:page name="foo.html" attribute="index" />
+ </browser:view>
+ """ % path , context=self._context)
def test_suite():
loader=unittest.TestLoader()
=== Zope3/src/zope/app/publisher/browser/tests/test_globalbrowsermenuservicedirectives.py 1.6 => 1.6.2.1 ===
--- Zope3/src/zope/app/publisher/browser/tests/test_globalbrowsermenuservicedirectives.py:1.6 Sun Aug 3 13:50:24 2003
+++ Zope3/src/zope/app/publisher/browser/tests/test_globalbrowsermenuservicedirectives.py Wed Aug 6 10:27:56 2003
@@ -11,24 +11,22 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""XXX short summary goes here.
-
-XXX longer description goes here.
-
+"""
$Id$
"""
-from StringIO import StringIO
from unittest import TestCase, main, makeSuite
-from zope.configuration.xmlconfig import xmlconfig, XMLConfig
from zope.publisher.browser import TestRequest
+from zope.configuration import xmlconfig
+
+import zope.app.publisher.browser
+import zope.app.configuration
+import zope.app.component.service
+
from zope.app.tests.placelesssetup import PlacelessSetup
from zope.app.publisher.browser.globalbrowsermenuservice \
import globalBrowserMenuService
-import zope.configuration
-
-import zope.app.publisher.browser
template = """<configure
xmlns='http://namespaces.zope.org/zope'
@@ -41,10 +39,18 @@
def setUp(self):
PlacelessSetup.setUp(self)
- XMLConfig('meta.zcml', zope.app.publisher.browser)()
+ self._config()
+
+ def _config(self):
+ sm = zope.app.component.service.globalServiceManager()
+ context = zope.app.configuration.ConfigurationMachine(sm)
+ xmlconfig.registerCommonDirectives(context)
+ xmlconfig.file('meta.zcml', package=zope.app.publisher.browser,
+ context=context)
+ self._context = context
def test(self):
- xmlconfig(StringIO(template % (
+ xmlconfig.string(template % (
"""
<browser:menu id="test_id" title="test menu" />
@@ -83,7 +89,8 @@
">
<browser:menuItem action="a9" title="t9" />
</browser:menuItems>
- """)))
+ """),
+ context=self._context)
from zope.app.publisher.browser.tests.test_globalbrowsermenuservice \
@@ -107,13 +114,14 @@
def testUsage(self):
- xmlconfig(StringIO(template % (
+ xmlconfig.string(template % (
"""
<browser:menu id="test_id" title="test menu" usage="objectview" />
<browser:menu id="test_id2" title="test menu" />
- """)))
+ """),
+ context=self._context)
self.assertEqual(globalBrowserMenuService.getMenuUsage('test_id'), u'objectview')
self.assertEqual(globalBrowserMenuService.getMenuUsage('test_id2'), u'')
=== Zope3/src/zope/app/publisher/browser/tests/test_icondirective.py 1.8 => 1.8.2.1 ===
--- Zope3/src/zope/app/publisher/browser/tests/test_icondirective.py:1.8 Sun Aug 3 13:50:24 2003
+++ Zope3/src/zope/app/publisher/browser/tests/test_icondirective.py Wed Aug 6 10:27:56 2003
@@ -12,27 +12,26 @@
#
##############################################################################
"""
-
-Revision information:
$Id$
"""
+
import os
-from StringIO import StringIO
from unittest import TestCase, main, makeSuite
from zope.exceptions import Forbidden
from zope.proxy import removeAllProxies
-from zope.app.tests.placelesssetup import PlacelessSetup
-from zope.configuration.xmlconfig import xmlconfig, XMLConfig
+from zope.configuration import xmlconfig
from zope.publisher.browser import TestRequest
from zope.component.tests.views import IC
from zope.publisher.interfaces.browser import IBrowserPresentation
from zope.component import queryView, getView, getResource
from zope.configuration.exceptions import ConfigurationError
-import zope.configuration
from zope.interface import implements
+import zope.app.configuration
+import zope.app.component.service
import zope.app.publisher.browser
+from zope.app.tests.placelesssetup import PlacelessSetup
template = """<configure
xmlns='http://namespaces.zope.org/zope'
@@ -61,9 +60,17 @@
def setUp(self):
PlacelessSetup.setUp(self)
- XMLConfig('meta.zcml', zope.app.publisher.browser)()
+ self._config()
defineCheckers()
+ def _config(self):
+ sm = zope.app.component.service.globalServiceManager()
+ context = zope.app.configuration.ConfigurationMachine(sm)
+ xmlconfig.registerCommonDirectives(context)
+ xmlconfig.file('meta.zcml', package=zope.app.publisher.browser,
+ context=context)
+ self._context = context
+
def test(self):
self.assertEqual(queryView(ob, 'zmi_icon', request), None)
@@ -71,13 +78,14 @@
path = os.path.split(p.__file__)[0]
path = os.path.join(path, 'test.gif')
- xmlconfig(StringIO(template % (
+ xmlconfig.string(template % (
"""
<browser:icon name="zmi_icon"
for="zope.component.tests.views.IC"
file="%s" />
""" % path
- )))
+ ),
+ context=self._context)
view = getView(ob, 'zmi_icon', request)
rname = 'zope-component-tests-views-IC-zmi_icon.gif'
@@ -102,7 +110,7 @@
path = os.path.split(p.__file__)[0]
path = os.path.join(path, 'test.gif')
- xmlconfig(StringIO(template % (
+ xmlconfig.string(template % (
"""
<browser:resource name="zmi_icon_res"
image="%s" />
@@ -110,7 +118,8 @@
for="zope.component.tests.views.IC"
resource="zmi_icon_res" />
""" % path
- )))
+ ),
+ context=self._context)
view = getView(ob, 'zmi_icon', request)
rname = "zmi_icon_res"
@@ -135,7 +144,7 @@
path = os.path.split(p.__file__)[0]
path = os.path.join(path, 'test.gif')
- config = StringIO(template % (
+ config = template % (
"""
<browser:resource name="zmi_icon_res"
image="%s" />
@@ -144,17 +153,18 @@
file="%s"
resource="zmi_icon_res" />
""" % (path, path)
- ))
- self.assertRaises(ConfigurationError, xmlconfig, config)
+ )
+ self.assertRaises(ConfigurationError, xmlconfig.string, config)
- config = StringIO(template % (
+ config = template % (
"""
<browser:icon name="zmi_icon"
for="zope.component.tests.views.IC"
/>
"""
- ))
- self.assertRaises(ConfigurationError, xmlconfig, config)
+ )
+ self.assertRaises(ConfigurationError, xmlconfig.string,
+ config, context=self._context)
def test_suite():
More information about the Zope3-Checkins
mailing list