[Numpy-discussion] Doctest items

Charles R Harris charlesr.harris@gmail....
Tue Jul 1 18:03:22 CDT 2008


On Tue, Jul 1, 2008 at 4:50 PM, Fernando Perez <fperez.net@gmail.com> wrote:

> On Tue, Jul 1, 2008 at 1:41 PM, Pauli Virtanen <pav@iki.fi> wrote:
>
> > But it's a custom tweak to doctest, so it might break at some point in
> > the future, and I don't love the monkeypatching here...
>
> Welcome to the joys of extending doctest/unittest.  They hardcoded so
> much stuff in there that the only way to reuse that code is by
> copy/paste/monkeypatch.  It's absolutely atrocious.
>
> >> We could always just make the plotting section one of those "it's just
> >> an example not a doctest" things and remove the ">>>" (since it doesn't
> >> appear to provide any useful test coverage or anything).
> >
> > If possible, I'd like other possibilities be considered first before
> > jumping this route. I think it would be nice to retain the ability to run
> > also the matplotlib examples as (optional) doctests, to make sure also
> > they execute correctly. Also, using two different markups in the
> > documentation to work around a shortcoming of doctest is IMHO not very
> > elegant.
>
> How about a much simpler approach?  Just pre-populate the globals dict
> where doctest executes with an object called 'plt' that basically does
>
> def noop(*a,**k): pass
>
> class dummy():
>  def __getattr__(self,k): return noop
>
> plt = dummy()
>
> This would ensure that all calls to plt.anything() silently succeed in
> the doctests.  Granted, we're not testing matplotlib, but it has the
> benefit of simplicity and of letting us keep consistent formatting,
> and examples that *users* can still paste into their sessions where
> plt refers to the real matplotlib.
>
> Just an idea...
>

That was my thought, but Robert didn't like it.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080701/1b758d4b/attachment.html 


More information about the Numpy-discussion mailing list