mò
ã¸Ec @ s€ d Z d k Z d k Z e d j o$ e e i i e i d d ƒ ƒ n d „ Z d „ Z d „ Z e d j o e
ƒ n d S( s] Test the basic ZCML directives
$Id: test_directives.py 70513 2006-10-04 03:06:57Z tseaver $
Nt __main__i s framework.pyc C s d S( s(
Test ZCML directives
There isn't much to test here since the actual directive handlers
are either tested in other, more specific tests, or they're
already tested in Zope 3. We'll just do a symbolic test of
adapters and overrides of adapters here as well as registering
meta directives.
But first, we load the configuration file:
>>> import Products.Five.tests
>>> from Products.Five import zcml
>>> zcml.load_config('meta.zcml', Products.Five)
>>> zcml.load_config('directives.zcml', Products.Five.tests)
Now for some testing. Here we check whether the registered
adapter works:
>>> from Products.Five.tests.adapters import IAdapted, IDestination
>>> from Products.Five.tests.adapters import Adaptable, Origin
>>> obj = Adaptable()
>>> adapted = IAdapted(obj)
>>> adapted.adaptedMethod()
'Adapted: The method'
Now let's load some overriding ZCML statements:
>>> zcml.load_string(
... '''''')
>>> origin = Origin()
>>> dest = IDestination(origin)
>>> dest.method()
'Overridden'
Check the result of the directives
>>> from Products.Five.tests.classes import One, Two, IOne, ITwo
>>> IOne.implementedBy(One)
True
>>> ITwo.implementedBy(One)
True
Clean up adapter registry and others:
>>> from zope.testing.cleanup import cleanUp
>>> cleanUp()
N( ( ( ( tB /data/zmath/zope/lib/python/Products/Five/tests/test_directives.pyt test_directives s 4c C s d S( s¹
Test deprecated content directive
There was a bug in the content directive deprecation code
which caused all code that use this directive break.
So we test this to make sure it works. If the content
directive will have been removed, this test can be removed
entirely as well.
First, we load the configuration file:
>>> import Products.Five.tests
>>> from Products.Five import zcml
>>> zcml.load_config('meta.zcml', Products.Five)
>>> zcml.load_config('directives.zcml', Products.Five.tests)
Use the directives: this gives a deprecation
warning but should otherwise be all right. (We embed the block
to suppress the deprecation warning...)
>>> import warnings
>>> warnings.showwarning, _savewarning = lambda *args, **kw: None, warnings.showwarning
>>> zcml.load_string('''
...
...
...
...
...
... ''')
Check that they are all right.
>>> from Products.Five.tests.classes import One, Two, IOne, ITwo
>>> IOne.implementedBy(One)
True
Clean up adapter registry and others:
>>> warnings.showwarning = _savewarning
>>> from zope.testing.cleanup import cleanUp
>>> cleanUp()
N( ( ( ( R t test_content_deprecationL s *c C s d k l } | ƒ S( N( s ZopeDocTestSuite( t Testing.ZopeTestCaset ZopeDocTestSuite( R ( ( R t
test_suitey s
( t __doc__t ost syst __name__t execfilet patht joinR R R t framework( R R R R R ( ( R t ? s
$ 6 -