[Checkins] SVN: z3c.pt/trunk/src/z3c/pt/template.txt Added tests to verify reduce/restore in conjunction with XIncludes.

Malthe Borch mborch at gmail.com
Wed Sep 10 18:13:33 EDT 2008


Log message for revision 91046:
  Added tests to verify reduce/restore in conjunction with XIncludes.

Changed:
  U   z3c.pt/trunk/src/z3c/pt/template.txt

-=-
Modified: z3c.pt/trunk/src/z3c/pt/template.txt
===================================================================
--- z3c.pt/trunk/src/z3c/pt/template.txt	2008-09-10 21:45:00 UTC (rev 91045)
+++ z3c.pt/trunk/src/z3c/pt/template.txt	2008-09-10 22:13:32 UTC (rev 91046)
@@ -204,8 +204,8 @@
 xi:include
 
   >>> from z3c.pt.template import BaseTemplateFile
-  >>> template = BaseTemplateFile(path+"/xinclude1.pt", mock_parser)
-  >>> print template()
+  >>> template1 = BaseTemplateFile(path+"/xinclude1.pt", mock_parser)
+  >>> print template1()
   <div xmlns="http://www.w3.org/1999/xhtml">
     <div>
     <span>Hello, world!</span>
@@ -217,8 +217,8 @@
 When using XInclude-statements in Genshi, macro-definitions are
 carried over from the included template. This is demonstrated below.
 
-  >>> template = BaseTemplateFile(path+"/xinclude3.pt", GenshiParser())
-  >>> print template()
+  >>> template2 = BaseTemplateFile(path+"/xinclude3.pt", GenshiParser())
+  >>> print template2()
   <div xmlns="http://www.w3.org/1999/xhtml">
   <BLANKLINE>
   <BLANKLINE>
@@ -227,8 +227,26 @@
     </p>
   <BLANKLINE>
   </div>
+
+Before we proceed, we reduce and restore the underlying byte-code
+template.
   
+  >>> from cPickle import dumps, loads
+  >>> for registry in (template1.registry, template2.registry):
+  ...     for key, bct in registry.items():
+  ...         registry[key] = loads(dumps(bct))
+
+  >>> print template2()
+  <div xmlns="http://www.w3.org/1999/xhtml">
+  <BLANKLINE>
+  <BLANKLINE>
+    <p class="greeting">
+      Hello, world!
+    </p>
+  <BLANKLINE>
+  </div>
   
+  
 Error handling
 --------------
 



More information about the Checkins mailing list