Re: testing problem with path expressions in page templates

Chris Withers <[email protected]>
Newsgroups gmane.comp.web.zope.devel
Message-ID <[email protected]>
Marius Gedminas wrote:
>> What adapter might that be and what's the "right" way to get it 
>> registered in a unit test?
> 
> DefaultTraversable, I think, and
> 
>         from zope.app.testing import setup
>         setup.setUpTraversal()
> 
> Various other features need various other components, e.g. if your
> template tries to use @@absolute_url, in addition to the above, you'll need
> 
>         provideAdapter(zope.traversing.namespace.view,
>                        adapts=(None, None),
>                        provides=ITraversable,
>                        name='view')
> 
> similarly for resources you do something like
> 
>         ztapi.provideView(Interface, Interface, ITraversable, 'resource',
>                           zope.traversing.namespace.resource)
>         ztapi.browserResource('style.css', ResourceStub)
> 
> and let's not even start talking about forms and widgets.
> 
> I'm not sure rendering page templates in unit tests is worth the pain.

Actually, it wasn't that bad:

from Products.Five import zcml

class Tests(unittest.TestCase):

     def setUp(self):
         cleanup.cleanUp()
         zcml._initialized = False
         zcml.load_site()

     def tearDown(self):
         cleanup.cleanUp()

cheers,

Chris

-- 
Simplistix - Content Management, Batch Processing & Python Consulting
            - http://www.simplistix.co.uk
_______________________________________________
Zope-Dev maillist  -  [email protected]
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.