[Zope-dev] Zope Tests: 10 OK, 4 Failed, 2 Unknown

Tres Seaver tseaver at palladion.com
Tue May 4 08:42:46 EDT 2010


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

Lennart Regebro wrote:
> On Mon, May 3, 2010 at 20:02, Tres Seaver <tseaver at 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          tseaver at 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-----


More information about the Zope-Dev mailing list