[TIP] Unittesting command line scripts with unittest2?
Jorge Vargas
jorge.vargas at gmail.com
Wed Jul 28 13:59:30 PDT 2010
I started writing some tests using this skeleton.
http://paste.ofcode.org/wr4JtC36nsMEWUVYPdSqj2
That is doing two things
1- silencing the print statements as well as the subprocess calls
2- giving me a variable to test the output.
So I have two questions, is this a good approach? is there a better
way? perhaps it should be abstracted into a separate module, maybe a
unittest2 plugin?
Also Today I realized there is something wrong with this approach. I'm
messing around with sys.argv which when called as `unit2 discover`
gives some troubles. In fact after upgrading to the plugins branch of
unittest2 I realized my tests are broken as sys.argv[1] will give an
error. I assume this is a side effect for getopt which was removed in
http://hg.python.org/unittest2/rev/0190b218cf49 therefore this is a
minor incompatibility between unittest2-0.5.1 and tip.
More information about the testing-in-python
mailing list