excluding unit test code

David Allen mda at idatar.com
Mon Apr 2 19:54:06 EDT 2001


In article <mailman.986231944.22965.python-list at python.org>, "Steven Haryanto"
<steven at haryan.to> wrote:

> Since an XP-faithful coder can write lots of test suites, is there a simple
> way to exclude these code in a module from the production code?
> 
> Steve

What do you mean by "exclude"?  If this were C, 
I'd say that you could just use "#if 0" around the
test blocks for when you ship production code.

The quick way is to convert:

some_test_code()

into

if None:
  some_test_code()

if that's OK with you.  That way it will never be
executed.  How else you would do it depends on your
definition of "excluded".  You could hide it in 
another module, or just cut it out altogether.

-- 
David Allen
http://opop.nols.com/
----------------------------------------
Great minds run in great circles.



More information about the Python-list mailing list