Arnaud Delobelle wrote:
Here is a very simple way to improve what you do, which won't require
you to change the way you work or to learn a new paradigm:

Instead of testing your functions interactively, put your testing code
in a file, e.g. 'program_tests.py'.  Your can then type

    python program_tests.py

at the shell interactive prompt.  To perform the tests again, just
re-execute that file.  If your tests are divided into
different units, you can put these in functions:

    def test_frobz():
        #testing code for frobzation of klops

    def test_frizz():
        #testing code for frizzment of frobzied klops

    # etc..

So if you want to keep doing interactive tests, you can import
program_tests and call whichever testing functions you want.  You may
even have arguments to those functions to test them with different
parameters.

I know some people will point at more 'pro' ways of testing but this has
the merit of being very straightforward.  Then when you move on to more
sophisticated techniques, I think you will understand better the
motivations behind them.

It took me some time to cotton on to exactly what you were saying, but once I grasped it and tried it out, I found it very effective and time-saving.

Thank you very much Arnaud.

--
Chandra
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to