excluding unit test code
Kragen Sitaker
kragen at dnaco.net
Mon Apr 2 18:35:48 EDT 2001
In article <mailman.986241843.21677.python-list at python.org>,
Steve Purcell <stephen_purcell at yahoo.com> wrote:
>Steven Haryanto 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?
>
>Yes -- put the test code in a separate module to the tested code!
>
>But consider shipping tests with production code anyway. You never know when
>they'll help you track down a problem.
My usual practice is to run module unit tests at import time. This
helps me laugh at people that tout compile-time checking as a strength
of low-level statically-typed languages. Obviously this becomes less
desirable as your test suite becomes slower; typically it adds a few
milliseconds (often as much as 20%) to the load time of my modules.
--
<kragen at pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Perilous to all of us are the devices of an art deeper than we possess
ourselves.
-- Gandalf the White [J.R.R. Tolkien, "The Two Towers", Bk 3, Ch. XI]
More information about the Python-list
mailing list