Mercurial > hg > configuration
diff tests/unit.py @ 89:0804a706d6bf
handle CLI errors with optparse
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sat, 28 Apr 2012 15:29:57 -0700 |
parents | 2a2e9aee5bc6 |
children | c530f6265deb |
line wrap: on
line diff
--- a/tests/unit.py Fri Apr 27 15:18:24 2012 -0700 +++ b/tests/unit.py Sat Apr 28 15:29:57 2012 -0700 @@ -78,12 +78,15 @@ example = ExampleConfiguration() - exception = None - try: - example.parse_args(args=[]) - except Exception, exception: - pass - self.assertTrue(isinstance(exception, configuration.MissingValueException)) + # monkey-patch the error method from optparse.OptionParser + error_msg = [] + def error(msg): + error_msg.append(msg) + example.error = error + + # trigger it + example.parse_args(args=[]) + self.assertEqual(error_msg, ['Parameter browser_path is required but not present']) def test_required(self): """ensure you have to have required values"""