mò ã¸Ec@s€dZdkZdkZedjo$eeiieiddƒƒnd„Zd„Zd„Z edjo e ƒndS(s]Test the basic ZCML directives $Id: test_directives.py 70513 2006-10-04 03:06:57Z tseaver $ Nt__main__is framework.pycCsdS(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.pyttest_directivess4cCsdS(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((((Rttest_content_deprecationLs*cCsdkl}|ƒS(N(sZopeDocTestSuite(tTesting.ZopeTestCasetZopeDocTestSuite(R((Rt test_suiteys ( t__doc__tostsyst__name__texecfiletpathtjoinRRRt framework(RRR RR((Rt?s $ 6 -