Testing python command line apps -- Running from within the projects w/o installing
Tim Chase
python.list at tim.thechases.com
Thu Oct 31 20:45:18 EDT 2013
On 2013-10-31 22:12, Göktuğ Kayaalp wrote:
> My usual practise is to have two entry points to the program as
> executable scripts.
When I create stand-alone command-line scripts that take arguments,
usually they're akin to version-control tools, so I have the form
scriptname.py [--global-opts] <command> [--command-opts] [args]
so I just make one of my <command>s allow for "test". That way, I
can execute my tests as easily as my program. If I've added config
parsing and script behavior depends on them, I might even create a
test harness that does something like
#!/bin/sh
for f in one.ini two.ini three.ini
do
scriptname.py --config="$f" test
done
That way, if some of my tests take a long time to run, I can even
make sub-commands to test a subset of the functionality to speed it
up:
scriptname.py test web-ui
scriptname.py test database
...
-tkc
More information about the Python-list
mailing list