[Zope] Unit Testing DTML and ZPT
Marco Bizzarri
marco.bizzarri at gmail.com
Thu Jul 26 07:09:54 EDT 2007
On 7/26/07, Chris Gray <cpgray at library.uwaterloo.ca> wrote:
> Is there any standard way of unit testing the two page templating
> methods in Zope 2?
>
> Chris
If you're trying to test the output produced by a dtml/zpt, you could
try to invoke it, inside a zopetestcase.
Something like:
self.app.index_html = PageTemplateFile(path_to_your_template, globals())
x = self.app.index_html();
self.assertEquals("some_string", x);
I'm using here PageTemplateFile, but you can do it with standard
ZopePageTemplate.
The problem is what you're trying to test (and, therefore, to assert).
Checking for equality is too fine grained, where you would check for
the structure of the zpt, for example. A little parser could be
useful.
Regards
Marco
--
Marco Bizzarri
http://iliveinpisa.blogspot.com/
More information about the Zope
mailing list