[Checkins] SVN: z3c.contents/trunk/src/z3c/contents/ Fix tests.

Marius Gedminas marius at pov.lt
Sun Dec 19 14:52:25 EST 2010


Log message for revision 119007:
  Fix tests.
  
  They were failing because of a combination of two, I don't know if I should
  call them bugs:
  
    (1) z3c.contents README.txt was registering a bunch of adapters into the
        local site, rather than into the global site.
  
    (2) z3c.copy was trying to make a copy of everything -- including the
        local site with non-persistable z3c:template adapters -- by pickling
        and unpickling.
  
  This thread has the full story:
  https://mail.zope.org/pipermail/zope-dev/2010-December/042202.html
  
  

Changed:
  U   z3c.contents/trunk/src/z3c/contents/README.txt
  U   z3c.contents/trunk/src/z3c/contents/tests.py

-=-
Modified: z3c.contents/trunk/src/z3c/contents/README.txt
===================================================================
--- z3c.contents/trunk/src/z3c/contents/README.txt	2010-12-19 16:55:08 UTC (rev 119006)
+++ z3c.contents/trunk/src/z3c/contents/README.txt	2010-12-19 19:52:24 UTC (rev 119007)
@@ -35,11 +35,16 @@
   >>> setupFormDefaults()
 
 And we need to configure our contents.pt template for the ContentsPage. We
-also configure the template for the search sub form here too.
+also configure the template for the search sub form here too.  And we
+make sure the configuration is applied to the global site manager, to
+avoid problems with unpicklable z3c:template adapters.
 
   >>> import os
   >>> import sys
   >>> from zope.configuration import xmlconfig
+  >>> from zope.component.hooks import setSite, getSite
+  >>> site = getSite()
+  >>> setSite(None)
   >>> import z3c.template
   >>> context = xmlconfig.file('meta.zcml', z3c.template)
   >>> contentsTemplate = os.path.join(os.path.dirname(z3c.contents.__file__),
@@ -90,7 +95,11 @@
   >>> request = TestRequest()
   >>> alsoProvides(request, IDivFormLayer)
 
+Restore the site now that we're done with the configuration.
 
+  >>> setSite(site)
+
+
 ContentsPage
 ------------
 

Modified: z3c.contents/trunk/src/z3c/contents/tests.py
===================================================================
--- z3c.contents/trunk/src/z3c/contents/tests.py	2010-12-19 16:55:08 UTC (rev 119006)
+++ z3c.contents/trunk/src/z3c/contents/tests.py	2010-12-19 19:52:24 UTC (rev 119007)
@@ -22,7 +22,8 @@
 
 from z3c.contents import testing
 
-functional.defineLayer('TestLayer', 'ftesting.zcml')
+functional.defineLayer('TestLayer', 'ftesting.zcml',
+                       allow_teardown=True)
 
 
 def test_suite():



More information about the checkins mailing list