Testing functions via command line

Steven D'Aprano steve at REMOVEME.cybersource.com.au
Tue Apr 3 02:04:02 EDT 2007


On Mon, 02 Apr 2007 22:32:26 -0700, pelon wrote:

> There must be a couple of lines that will replace the following:

Yes, because otherwise the terrorists will have won. *wink*



> From the shell command line I wanted to send data to a specific
> function inside my module and execute that function in order to test
> it separately from the rest of the module.

For manual testing, why don't you do your testing from the interactive
Python shell?

e.g.

$ python
Python 2.3.4 (#1, Oct 11 2006, 06:18:43)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> import my_module
>>> my_module.function('something') # test the function

Am I missing something?

Also, while your self-test code is very ingenious, perhaps you would be
better off using standard testing modules. Perhaps you should use the
doctest and/or unittest modules.



-- 
Steven D'Aprano 




More information about the Python-list mailing list