Skip to content
This repository has been archived by the owner on Dec 17, 2020. It is now read-only.

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mgedmin committed Dec 19, 2010
1 parent 3102a05 commit 6239696
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/z3c/contents/README.txt
Expand Up @@ -35,11 +35,16 @@ And we need to setup the form defaults first:
>>> 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__),
Expand Down Expand Up @@ -90,6 +95,10 @@ And support the div form layer for our request:
>>> request = TestRequest()
>>> alsoProvides(request, IDivFormLayer)

Restore the site now that we're done with the configuration.

>>> setSite(site)


ContentsPage
------------
Expand Down
3 changes: 2 additions & 1 deletion src/z3c/contents/tests.py
Expand Up @@ -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():
Expand Down

0 comments on commit 6239696

Please sign in to comment.