[Zope-dev] Avoid deprecation warnings in the testrunner
Fabio Tranchitella
kobold at kobold.it
Wed Dec 23 08:38:26 EST 2009
Hello,
* 2009-12-23 14:33, Marius Gedminas wrote:
> > @@ -328,6 +327,9 @@
> > def format_traceback(self, exc_info):
> > """Format the traceback."""
> > v = exc_info[1]
> > + warnings.simplefilter('ignore')
> > + from zope.testing import doctest
> > + warnings.filters.pop()
>
> I'm not thrilled.
Me neither, but if I don't do that, I will have a lot of test failures
because the deprecation warning will be printed in the middle of the tests.
> Can we 'import doctest' from the stdlib, and hope that these isinstance
> checks work fine?
No, it doesn't because the first if is about an exception which is
zope.testing.doctest-specific.
> Specifically, can we make it so that zope.testing.doctest's exceptions
> _inherit_ from stdlib's doctest exceptions?
I couldn't find the way to do it.
> > ===================================================================
> > --- src/zope/testing/testrunner/doctest.py (revisione 106999)
> > +++ src/zope/testing/testrunner/doctest.py (copia locale)
> > @@ -17,10 +17,11 @@
> > """
> >
> > import sys
> > -from zope.testing import doctest
> > import zope.testing.testrunner.feature
> >
> > +from zope.testing import doctest
> >
> > +
>
> Doesn't seem like much of a change ;)
> Suggest importing stdlib here as well.
Same reason, we cannot use the standard doctest because it doesn't have
the feature needed there.
> > - self.features.append(zope.testing.testrunner.doctest.DocTest(self))
> > + if options.ndiff or options.udiff or options.cdiff or \
> > + options.report_only_first_failure is not None:
> > + from zope.testing.testrunner.doctest import DocTest
> > + self.features.append(DocTest(self))
>
> A *strong* -1 for this bit.
This is the only way I could avoid deprecation warnings for a test that
doesn't need zope.testing-specific doctest features. Better ideas?
Fabio
More information about the Zope-Dev
mailing list