Unit testing Cmd module derived classes
Posted in Code and machines, Python on February 19th, 2012 by admin – 2 CommentsI’ll update this once I’ve figured it out.
I’m writing a customised command-line task manager in Python using the Cmd module. I’ve decided, for practice, to use nice test-driven development so I’ve kicked it off with a very simple Cmd-derived class and a corresponding test class. I’ve added a few very simple methods kicked off by the cmdloop() method but of course in my test class I’d like to create an instance of my cmd-derived class , invoke the cmdloop() and send it some input.
How do I send my object some input from my test method?