[Checkins] SVN: grok/trunk/ Foward port from the 0.11 branch:

Philipp von Weitershausen philikon at philikon.de
Sun Nov 11 06:15:48 EST 2007


Log message for revision 81749:
  Foward port from the 0.11 branch:
  
  ------------------------------------------------------------------------
  r81744 | philikon | 2007-11-11 12:07:19 +0100 (Sun, 11 Nov 2007) | 5 lines
  
    Fix https://bugs.launchpad.net/grok/+bug/161948: grok.testing.grok()
    now also loads the ZPT template factories so that unit tests that
    need to configure views with ZPT templates continue to work.
  
  
  ------------------------------------------------------------------------
  r81746 | philikon | 2007-11-11 12:11:15 +0100 (Sun, 11 Nov 2007) | 5 lines
  
    Changed a few remaining references to ``grok.grok`` and
    ``grok.grok_component`` to their correct equivalents in
    ``grok.testing``.
  
  
  ------------------------------------------------------------------------
  
  

Changed:
  U   grok/trunk/CHANGES.txt
  U   grok/trunk/src/grok/testing.py
  U   grok/trunk/src/grok/tests/grokker/grokcomponent.py
  U   grok/trunk/src/grok/tests/template/pluggability.py
  A   grok/trunk/src/grok/tests/template/zpt.py
  A   grok/trunk/src/grok/tests/template/zpt_templates/
  U   grok/trunk/src/grok/tests/view/dirandinlinetemplate.py
  U   grok/trunk/src/grok/tests/view/dirtemplate.py
  U   grok/trunk/src/grok/tests/view/dirtemplateandrender.py
  U   grok/trunk/src/grok/tests/view/dirtemplatesonly.py
  U   grok/trunk/src/grok/tests/view/templatedirectory.py
  U   grok/trunk/src/grok/tests/view/templatereload.py
  U   grok/trunk/src/grok/tests/view/unassociated.py
  U   grok/trunk/src/grok/tests/zcml/directivepackage.py

-=-
Modified: grok/trunk/CHANGES.txt
===================================================================
--- grok/trunk/CHANGES.txt	2007-11-11 11:13:47 UTC (rev 81748)
+++ grok/trunk/CHANGES.txt	2007-11-11 11:15:47 UTC (rev 81749)
@@ -4,8 +4,17 @@
 0.12 (unreleased)
 =================
 
-* ...
+Bug fixes
+---------
 
+* Fix https://bugs.launchpad.net/grok/+bug/161948: grok.testing.grok()
+  now also loads the ZPT template factories so that unit tests that
+  need to configure views with ZPT templates continue to work.
+
+* Changed a few remaining references to ``grok.grok`` and
+  ``grok.grok_component`` to their correct equivalents in
+  ``grok.testing``.
+
 0.11 (2007-11-08)
 =================
 

Modified: grok/trunk/src/grok/testing.py
===================================================================
--- grok/trunk/src/grok/testing.py	2007-11-11 11:13:47 UTC (rev 81748)
+++ grok/trunk/src/grok/testing.py	2007-11-11 11:15:47 UTC (rev 81749)
@@ -20,6 +20,7 @@
 def grok(module_name):
     config = ConfigurationMachine()
     zcml.do_grok('grok.meta', config)
+    zcml.do_grok('grok.templatereg', config)
     zcml.do_grok(module_name, config)
     config.execute_actions()
 

Modified: grok/trunk/src/grok/tests/grokker/grokcomponent.py
===================================================================
--- grok/trunk/src/grok/tests/grokker/grokcomponent.py	2007-11-11 11:13:47 UTC (rev 81748)
+++ grok/trunk/src/grok/tests/grokker/grokcomponent.py	2007-11-11 11:15:47 UTC (rev 81749)
@@ -18,7 +18,7 @@
 
 To grok this adapter, you can simply write this::
 
-  >>> grok.grok_component('MyAdapter', MyAdapter)
+  >>> grok.testing.grok_component('MyAdapter', MyAdapter)
   True
 
 We can now use the adapter::
@@ -40,14 +40,14 @@
 This adapter does not supply its own context. Trying to do what we did
 before will therefore fail::
 
-  >>> grok.grok_component('SecondAdapter', SecondAdapter)
+  >>> grok.testing.grok_component('SecondAdapter', SecondAdapter)
   Traceback (most recent call last):
     ...
   GrokError: No module-level context for <class 'grok.tests.grokker.grokcomponent.SecondAdapter'>, please use grok.context.
 
 So we need to supply the context ourselves::
 
-  >>> grok.grok_component('SecondAdapter', SecondAdapter, context=SomeClass)
+  >>> grok.testing.grok_component('SecondAdapter', SecondAdapter, context=SomeClass)
   True
 
 Now we can use the SecondAdapter as well::

Modified: grok/trunk/src/grok/tests/template/pluggability.py
===================================================================
--- grok/trunk/src/grok/tests/template/pluggability.py	2007-11-11 11:13:47 UTC (rev 81748)
+++ grok/trunk/src/grok/tests/template/pluggability.py	2007-11-11 11:15:47 UTC (rev 81749)
@@ -1,7 +1,7 @@
 """
 Testing the plugging in of a template language
 
-  >>> grok.grok(__name__)
+  >>> grok.testing.grok(__name__)
   
   >>> cave = Cave()
   >>> from zope.publisher.browser import TestRequest

Copied: grok/trunk/src/grok/tests/template/zpt.py (from rev 81746, grok/branches/0.11/src/grok/tests/template/zpt.py)
===================================================================
--- grok/trunk/src/grok/tests/template/zpt.py	                        (rev 0)
+++ grok/trunk/src/grok/tests/template/zpt.py	2007-11-11 11:15:47 UTC (rev 81749)
@@ -0,0 +1,22 @@
+"""
+
+  >>> grok.testing.grok(__name__)
+
+  >>> cave = Cave()
+  >>> from zope.publisher.browser import TestRequest
+  >>> request = TestRequest()
+  >>> from zope.component import getMultiAdapter
+
+  >>> view = getMultiAdapter((cave, request), name='piepmatz')
+  >>> print view()
+  <p>Piep! Piep!</p>
+
+"""
+
+import grok
+
+class Cave(grok.Model):
+    pass
+
+class Piepmatz(grok.View):
+    pass # template in zpt_templates/piepmatz.pt

Copied: grok/trunk/src/grok/tests/template/zpt_templates (from rev 81746, grok/branches/0.11/src/grok/tests/template/zpt_templates)

Modified: grok/trunk/src/grok/tests/view/dirandinlinetemplate.py
===================================================================
--- grok/trunk/src/grok/tests/view/dirandinlinetemplate.py	2007-11-11 11:13:47 UTC (rev 81748)
+++ grok/trunk/src/grok/tests/view/dirandinlinetemplate.py	2007-11-11 11:15:47 UTC (rev 81749)
@@ -2,7 +2,6 @@
 If multiple templates can be found, one in the module and one in the
 template directory, there is an error:
 
-  >>> grok.testing.grok('grok.templatereg')
   >>> grok.testing.grok(__name__)
   Traceback (most recent call last):
     ...

Modified: grok/trunk/src/grok/tests/view/dirtemplate.py
===================================================================
--- grok/trunk/src/grok/tests/view/dirtemplate.py	2007-11-11 11:13:47 UTC (rev 81748)
+++ grok/trunk/src/grok/tests/view/dirtemplate.py	2007-11-11 11:15:47 UTC (rev 81749)
@@ -1,7 +1,6 @@
 """
 Templates can also be found in a directory with the same name as the module:
 
-  >>> grok.testing.grok('grok.templatereg')
   >>> grok.testing.grok(__name__)
   
   >>> manfred = Mammoth()

Modified: grok/trunk/src/grok/tests/view/dirtemplateandrender.py
===================================================================
--- grok/trunk/src/grok/tests/view/dirtemplateandrender.py	2007-11-11 11:13:47 UTC (rev 81748)
+++ grok/trunk/src/grok/tests/view/dirtemplateandrender.py	2007-11-11 11:15:47 UTC (rev 81749)
@@ -2,7 +2,6 @@
 A View may either have an associated template or a render-method. Here
 we check that this also works for templates in a template-directory:
 
-  >>> grok.testing.grok('grok.templatereg')
   >>> grok.testing.grok(__name__)
   Traceback (most recent call last):
     ...

Modified: grok/trunk/src/grok/tests/view/dirtemplatesonly.py
===================================================================
--- grok/trunk/src/grok/tests/view/dirtemplatesonly.py	2007-11-11 11:13:47 UTC (rev 81748)
+++ grok/trunk/src/grok/tests/view/dirtemplatesonly.py	2007-11-11 11:15:47 UTC (rev 81749)
@@ -6,7 +6,6 @@
   >>> warnings.warn = warn
 
 
-  >>> grok.testing.grok('grok.templatereg')
   >>> grok.testing.grok(__name__)
     From tests.py's showwarning():
     ... UserWarning: File 'invalid.txt' has an unrecognized extension in directory '...dirtemplatesonly_templates'...

Modified: grok/trunk/src/grok/tests/view/templatedirectory.py
===================================================================
--- grok/trunk/src/grok/tests/view/templatedirectory.py	2007-11-11 11:13:47 UTC (rev 81748)
+++ grok/trunk/src/grok/tests/view/templatedirectory.py	2007-11-11 11:15:47 UTC (rev 81749)
@@ -1,7 +1,6 @@
 """
 You can explicitly specify the template directory using grok.templatedir on module level:
 
-  >>> grok.testing.grok('grok.templatereg')
   >>> grok.testing.grok(__name__)
 
   >>> manfred = Mammoth()

Modified: grok/trunk/src/grok/tests/view/templatereload.py
===================================================================
--- grok/trunk/src/grok/tests/view/templatereload.py	2007-11-11 11:13:47 UTC (rev 81748)
+++ grok/trunk/src/grok/tests/view/templatereload.py	2007-11-11 11:15:47 UTC (rev 81749)
@@ -2,7 +2,6 @@
 Filesystem-based templates, once grokked, can be changed.  The change
 will automatically be picked up, reloading Zope is not necessary.
 
-  >>> grok.testing.grok('grok.templatereg')
   >>> grok.testing.grok(__name__)
   >>> from zope.component import getMultiAdapter
   >>> from zope.publisher.browser import TestRequest

Modified: grok/trunk/src/grok/tests/view/unassociated.py
===================================================================
--- grok/trunk/src/grok/tests/view/unassociated.py	2007-11-11 11:13:47 UTC (rev 81748)
+++ grok/trunk/src/grok/tests/view/unassociated.py	2007-11-11 11:15:47 UTC (rev 81749)
@@ -2,7 +2,6 @@
 Templates that are not associated with a view class will provoke an
 error:
 
-  >>> grok.testing.grok('grok.templatereg')
   >>> grok.testing.grok(__name__)
   Traceback (most recent call last):
   ...

Modified: grok/trunk/src/grok/tests/zcml/directivepackage.py
===================================================================
--- grok/trunk/src/grok/tests/zcml/directivepackage.py	2007-11-11 11:13:47 UTC (rev 81748)
+++ grok/trunk/src/grok/tests/zcml/directivepackage.py	2007-11-11 11:15:47 UTC (rev 81749)
@@ -3,14 +3,12 @@
   >>> from zope.configuration import xmlconfig
   >>> context = xmlconfig.file('meta.zcml', grok)
 
-Load the ZPT factory
-  >>> grok.testing.grok('grok.templatereg')
-
   >>> ignored = xmlconfig.string('''
   ... <configure
   ...     xmlns="http://namespaces.zope.org/zope"
   ...     xmlns:grok="http://namespaces.zope.org/grok"
   ...     >
+  ...     <grok:grok package="grok.templatereg"/>
   ...     <grok:grok package="grok.tests.zcml.stoneage"/>
   ... </configure>''', context=context)
 



More information about the Checkins mailing list