470,849 Members | 1,225 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,849 developers. It's quick & easy.

How to doctest if __name__ already used?

I have a simple question (I hope), but one I'd love to get some
feedback on in case I am missing something obvious:

If I have a Python script that is executable, and therefore
already uses '''if __name__ == "__main__"''' to call a function
of its own, what is then the easiest yet still most Pythonic way
to run doctest on the docstrings in the file?

Trigger doctest.testmod() via a "--test" command-line option, is
what I'm thinking. But is that really the best way?

--
Leo Breebaart <le*@lspace.org>
May 5 '06 #1
2 1163
On Fri, May 05, 2006 at 10:33:48PM +0000, Leo Breebaart wrote:
Trigger doctest.testmod() via a "--test" command-line option, is
what I'm thinking. But is that really the best way?

That is what I would have suggested.

-Chris
May 7 '06 #2

On May 5, 2006, at 10:33 PM, Leo Breebaart wrote:
I have a simple question (I hope), but one I'd love to get some
feedback on in case I am missing something obvious:

If I have a Python script that is executable, and therefore
already uses '''if __name__ == "__main__"''' to call a function
of its own, what is then the easiest yet still most Pythonic way
to run doctest on the docstrings in the file?

Trigger doctest.testmod() via a "--test" command-line option, is
what I'm thinking. But is that really the best way?


If it is just a single standalone script, then yeah, do it that way.
Once your program becomes a few files though, you might want a separate
"test" file that runs doctest.testmod on each of them.

Jay P.

May 7 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Pierre Rouleau | last post: by
5 posts views Thread by Michele Simionato | last post: by
24 posts views Thread by john_sips_tea | last post: by
1 post views Thread by Michael Tobis | last post: by
reply views Thread by Leo | last post: by
reply views Thread by davidlmontgomery | last post: by
3 posts views Thread by Berthold Höllmann | last post: by
12 posts views Thread by thomas.guest | last post: by
4 posts views Thread by petr.jakes.tpc | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.