This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author r.david.murray
Recipients bethard, ezio.melotti, maker, r.david.murray
Date 2010-11-20.03:57:58
SpamBayes Score 1.7208457e-15
Marked as misclassified No
Message-id <1290225480.63.0.233466562242.issue10424@psf.upfronthosting.co.za>
In-reply-to
Content
There are currently no tests in argparse that test the content of error messages, which is fairly standard for stdlib tests since the error messages aren't considered part of the API (only the nature of the exception is).  So there's really no existing test class in test_argparse that would be an appropriate place to put a unit test for this.  

I would instead create a new class.  Perhaps TestErrorContent?  For this test it would probably be best to use assertRaisesRegexp and just check to make sure that the expected list of argument names appears in the message (that is, don't test the contents of the remainder of the message).  You should test several combinations.  (The argparse tests do some fancy footwork around errors, though, so you may not be able to use assertRaisesRegexp directly).

Your approach to the patch, by the way, is an interesting one, and seems to me to make sense.  But I'm not 100% sure I understand the logic of the code you are modifying, so I'll leave it to Steven to comment on that aspect of it :)

Your reference to TestArgumentError reveals a minor bug in the tests: there are actually two test classes named TestArgumentError.  Presumably the second one was indeed supposed to be TestArgumentTypeError.  I've fixed that in r86542.
History
Date User Action Args
2010-11-20 03:58:00r.david.murraysetrecipients: + r.david.murray, bethard, ezio.melotti, maker
2010-11-20 03:58:00r.david.murraysetmessageid: <1290225480.63.0.233466562242.issue10424@psf.upfronthosting.co.za>
2010-11-20 03:57:58r.david.murraylinkissue10424 messages
2010-11-20 03:57:58r.david.murraycreate