vendredi 25 mars 2016

TestCase for testing Optparse bad/missing argument

I want to test the options/arguments being passed to my code and their expected outcome. I am using Optparse to accept these arguments. Right now the code I am testing simply executes

parser.error("Some message")

when I am missing an argument or if I passed a bad argument.

Upon entering a bad argument. How can I test for this? Which method within unittest.TestCase do I use to assert that parser.error() occurred?

Aucun commentaire:

Enregistrer un commentaire