def test_help(self): args = r"-h".split() with self.assertRaises(SystemExit) as cm: main(args) the_exception = cm.exception self.assertEqual(the_exception.code, 0)
def test_preserve_order(self): myOut = StringIO.StringIO() with stdout_redirected(myOut): args = r"-k 10 words.txt --preserve-order".split() main(args) output = myOut.getvalue().strip() self.assertTrue(output) self.assertEqual(len(output.splitlines()), 10)