-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lennart Regebro wrote:
> 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
> sense.
> 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(
>         filename,
>         setUp=pageSetUp, tearDown=zope.component.testing.tearDown,
>         globs={'__file__':
> 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.

Cool.  I was afraid we were looking at something more insidious than that.


Tres.
- --
===================================================================
Tres Seaver          +1 540-429-0999          tsea...@palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkvgFckACgkQ+gerLs4ltQ7mtwCfSlKCCD/dyzxDjT1SQTWokT5F
qaAAoNYBsgA/PqKHdhnLXtRE9iJFy0Im
=P4PS
-----END PGP SIGNATURE-----
_______________________________________________
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )

Reply via email to