[Checkins] SVN: z3c.pt/trunk/ Added tests for error-handling;
minor corrections to existing tests.
Malthe Borch
mborch at gmail.com
Sat Dec 22 16:28:32 EST 2007
Log message for revision 82403:
Added tests for error-handling; minor corrections to existing tests.
Changed:
U z3c.pt/trunk/docs/HISTORY.txt
U z3c.pt/trunk/z3c/pt/README.txt
U z3c.pt/trunk/z3c/pt/tests/view.pt
U z3c.pt/trunk/z3c/pt/translation.txt
-=-
Modified: z3c.pt/trunk/docs/HISTORY.txt
===================================================================
--- z3c.pt/trunk/docs/HISTORY.txt 2007-12-22 21:27:02 UTC (rev 82402)
+++ z3c.pt/trunk/docs/HISTORY.txt 2007-12-22 21:28:32 UTC (rev 82403)
@@ -1,8 +1,8 @@
Changelog
---------
-Version 0.3 - December 21, 2007
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Version 0.3 - in development
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Added ``ViewPageTemplateFile`` class
[malthe]
Modified: z3c.pt/trunk/z3c/pt/README.txt
===================================================================
--- z3c.pt/trunk/z3c/pt/README.txt 2007-12-22 21:27:02 UTC (rev 82402)
+++ z3c.pt/trunk/z3c/pt/README.txt 2007-12-22 21:28:32 UTC (rev 82403)
@@ -48,5 +48,5 @@
<span><MockView object at ...</span>
<span>my context</span>
<span>my request</span>
- <span>{'test': u'my test'}</span>
+ <span>my test</span>
</div>
Modified: z3c.pt/trunk/z3c/pt/tests/view.pt
===================================================================
--- z3c.pt/trunk/z3c/pt/tests/view.pt 2007-12-22 21:27:02 UTC (rev 82402)
+++ z3c.pt/trunk/z3c/pt/tests/view.pt 2007-12-22 21:28:32 UTC (rev 82403)
@@ -3,5 +3,5 @@
<span tal:content="view" />
<span tal:content="context" />
<span tal:content="request" />
- <span tal:content="options" />
+ <span tal:content="options.test" />
</div>
Modified: z3c.pt/trunk/z3c/pt/translation.txt
===================================================================
--- z3c.pt/trunk/z3c/pt/translation.txt 2007-12-22 21:27:02 UTC (rev 82402)
+++ z3c.pt/trunk/z3c/pt/translation.txt 2007-12-22 21:28:32 UTC (rev 82403)
@@ -1,14 +1,26 @@
Translation
-----------
+This document contains functional template tests covering the TAL
+directives.
+
>>> from z3c.pt.translation import translate
-Example:
+ >>> def render(body, **kwargs):
+ ... source, _globals = translate(body)
+ ... _locals = {}
+ ... exec source in _globals, _locals
+ ... return _locals['render'](**kwargs)
+
+Canonical test template
+-----------------------
>>> body = """\
... <div xmlns="http://www.w3.org/1999/xhtml"
... xmlns:tal="http://xml.zope.org/namespaces/tal">
- ... <span tal:define="a 'abc'"
+ ... <span id="test"
+ ... class="dummy"
+ ... tal:define="a 'abc'"
... tal:attributes="class 'def' + a"
... tal:content="a + 'ghi'" />
... <ul>
@@ -19,12 +31,9 @@
... </div>
... """
- >>> source, _globals = translate(body)
- >>> _locals = {}
- >>> exec source in _globals, _locals
- >>> print _locals['render']()
+ >>> print render(body)
<div>
- <span class="defabc">abcghi</span>
+ <span id="test" class="defabc">abcghi</span>
<ul>
<li>
Item 0)
@@ -43,3 +52,39 @@
</li>
</ul>
</div>
+
+Error handling
+--------------
+
+This section demonstrates how the package handles templates that
+contain errors.
+
+No default namespace declaration:
+ A default namespace must be explicitly declared for the parser to work.
+
+ >>> body = '<br />'
+ >>> render(body)
+ Traceback (most recent call last):
+ ...
+ ValueError: Must set default namespace.
+
+Bad XML
+ We expect the xml-parser to raise an exception.
+
+ >>> body = '<div xmlns="http://www.w3.org/1999/xhtml"'
+ >>> render(body)
+ Traceback (most recent call last):
+ ...
+ XMLSyntaxError: line 1: Couldn't find end of Start Tag div line 1
+
+Missing namespace definition:
+ We expect the engine to render the attributes as static.
+
+ >>> body = """\
+ ... <div xmlns="http://www.w3.org/1999/xhtml" tal:content="'Hello World'" />
+ ... """
+
+ >>> print render(body)
+ <div content="'Hello World'" />
+
+
More information about the Checkins
mailing list