summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorsteven.bethard <devnull@localhost>2009-10-24 15:40:25 +0000
committersteven.bethard <devnull@localhost>2009-10-24 15:40:25 +0000
commitbc9332c5e33065a637797d739363236b01eb57d3 (patch)
tree9faaa37bd4947021b098a2119be454bb91735a87 /test
parent03eef47787030206ee5b34a06b1f3e8084998838 (diff)
downloadargparse-bc9332c5e33065a637797d739363236b01eb57d3.tar.gz
Better error messages for invalid actions.
Diffstat (limited to 'test')
-rw-r--r--test/test_argparse.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/test/test_argparse.py b/test/test_argparse.py
index 0bd06ca..c1717dc 100644
--- a/test/test_argparse.py
+++ b/test/test_argparse.py
@@ -3613,8 +3613,16 @@ class TestInvalidArgumentConstructors(TestCase):
self.assertValueError('---')
def test_invalid_action(self):
- self.assertTypeError('-x', action='foo')
- self.assertTypeError('foo', action='baz')
+ self.assertValueError('-x', action='foo')
+ self.assertValueError('foo', action='baz')
+ parser = argparse.ArgumentParser()
+ try:
+ parser.add_argument("--foo", action="store-true")
+ except ValueError:
+ e = sys.exc_info()[1]
+ expected = 'unknown action'
+ msg = 'expected %r, found %r' % (expected, e)
+ self.failUnless(expected in str(e), msg)
def test_no_argument_actions(self):
for action in ['store_const', 'store_true', 'store_false',