On Mon, May 3, 2010 at 20:02, Tres Seaver <tsea...@palladion.com> wrote:
> - - zope.browserpage
> - - zope.viewlet
> - - zope.contentprovider
> - - zope.deferredimport

These tests all fail because as Tres pointed out, Python 2.4 doesn't
set __file__ to the doctest filename in the globals. Zope.browserpage
in turn uses those globals to determine the filename of the
pagetemplate. So, you get an error if you create a browserpage in a
DocTestFile, like so:

  ErrorPage = SimpleViewClass(errorFileName, name='error.html')

Passing in file explicitly solves the problem:

  ErrorPage = SimpleViewClass(errorFileName, name='error.html',
offering={'__file__': 'README.txt'})

The same thing goes for ViewPagetemplateFile, but there it's called
_prefix instead of offering. Yeah, none of those variable names make
It can also typically be fixed by passing in __file__ explicitly to the doctest:

def test_suite():
    import doctest
    filename = os.path.join(os.pardir, 'namedtemplate.txt')
    return doctest.DocFileSuite(
        setUp=pageSetUp, tearDown=zope.component.testing.tearDown,
os.path.abspath(os.path.join(os.path.dirname(__file__), filename))}

Other options is to make the usage of __file__ lazy, so that it's only
looked up in the globals when accessed. Because I suspect it's not
actually used except when you get errors, but I'm not 100% sure.

So for the time being, I went for passing in __file__ explicitly in
globs.  The tests run under Python 2.4 again.

Lennart Regebro: Python, Zope, Plone, Grok
+33 661 58 14 64
Zope-Dev maillist  -  Zope-Dev@zope.org
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope )

Reply via email to