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 mapleoin
Recipients bethard, flox, mapleoin
Date 2012-07-07.14:58:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1341673128.13.0.485965286522.issue15271@psf.upfronthosting.co.za>
In-reply-to
Content
So I was looking into this and it seems that there are (at least) two contradicting test cases. When inheriting a parser from two parents, there are two different behaviours for positionals and for options.

In the case of positionals, there is this test:

def test_same_argument_name_parents(self):
        parents = [self.wxyz_parent, self.z_parent]
        parser = ErrorRaisingArgumentParser(parents=parents)
        self.assertEqual(parser.parse_args('1 2'.split()),
                         NS(w=None, y=None, z='2'))

and this is the context from higher up:

self.wxyz_parent.add_argument('z')
...
self.z_parent.add_argument('z')

So the tests don't expect an error when two parents provide the same argument. Instead, the eating up of the first argument (in this case '1') seems to be condoned?


When I tried to change the conflict_handler during parent action merging to 'resolve' I got another test failing:

def test_conflicting_parents(self):
        self.assertRaises(
            argparse.ArgumentError,
            argparse.ArgumentParser,
            parents=[self.w_parent, self.wxyz_parent])

context:

self.wxyz_parent.add_argument('--w')
...
self.w_parent.add_argument('--w')

This tests that two parents which provide the exact same option will raise an error.


So I think the first test is wrong and should be modified to expect an error in the case where two arguments with the same name are provided. Or is there some use case where this behaviour makes sense?
History
Date User Action Args
2012-07-07 14:58:48mapleoinsetrecipients: + mapleoin, bethard, flox
2012-07-07 14:58:48mapleoinsetmessageid: <1341673128.13.0.485965286522.issue15271@psf.upfronthosting.co.za>
2012-07-07 14:58:47mapleoinlinkissue15271 messages
2012-07-07 14:58:46mapleoincreate