Testing python command line apps -- Running from within the projects w/o installing

Göktuğ Kayaalp self at gkayaalp.com
Sat Nov 2 04:37:16 EDT 2013


> [...]
> Testing at levels of abstraction above the unit is important, but
> Python's ‘unittest’ is not a good fit. You'll need a different tool.
>
> For behaviour testing, I recommend Behave, which lets you describe
> assertions in English and have them automatically tested
> <URL:https://pypi.python.org/pypi/behave/>.
> 
> For integration testing, I recommend an automated build system like
> Jenkins <URL:http://jenkins-ci.org/> which can get your full source
> tree, build it using your build system, and run all your arbitrary test
> commands.
> 
> For running arbitrary commands as tests, you might be interested in
> Atheist <URL:http://arco.esi.uclm.es/~david.villa/atheist/html/>. I
> haven't tried it.
> 

Thank you Ben!  I would never find these until I was desparate to do so.
Also, via these links, I have found pointers to many other useful things
too, namely behave4cmd (incubating, no code) and django-behave.

> > I write a secondary script, 'app_tester', which is similar to 'app',
> > but before running app.main.main, it inserts ~/app to the front of
> > sys.path.
> 
> I think that's a poor solution. It's the worst of both worlds: you have
> a special-case tool, but one that doesn't actually test the application
> properly since it's not a very accurate representation of how the
> application will actually be installed. Better is simply using the build
> system to do a real, temporary install, and running the tests in there.
> 

Yes, I better use virtualenvs for their purpose. I'll think of "edit -
install to virtualenv - test" cycle as "edit - compile - run" cycle for
AOT-compiled languages from now on.  Or maybe I will use CI tools to
automate this, but I am to alien to CI to assert anything.

> -- 
>  \        “Odious ideas are not entitled to hide from criticism behind |
>   `\          the human shield of their believers' feelings.” —Richard |
> _o__)                                                         Stallman |
> Ben Finney
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20131102/bbb7782d/attachment.sig>


More information about the Python-list mailing list