Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing unittests for overlapping dest when using subparsers #89794

Open
paulj3 mannequin opened this issue Oct 27, 2021 · 2 comments
Open

missing unittests for overlapping dest when using subparsers #89794

paulj3 mannequin opened this issue Oct 27, 2021 · 2 comments
Assignees
Labels
tests Tests in the Lib/test dir

Comments

@paulj3
Copy link
Mannequin

paulj3 mannequin commented Oct 27, 2021

BPO 45631
Nosy @rhettinger, @ALSchwalm

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2021-10-27.16:36:51.812>
labels = []
title = 'missing unittests for overlapping dest when using subparsers'
updated_at = <Date 2021-10-27.16:36:51.812>
user = 'https://bugs.python.org/paulj3'

bugs.python.org fields:

activity = <Date 2021-10-27.16:36:51.812>
actor = 'paul.j3'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = []
creation = <Date 2021-10-27.16:36:51.812>
creator = 'paul.j3'
dependencies = []
files = []
hgrepos = []
issue_num = 45631
keywords = []
message_count = 1.0
messages = ['405110']
nosy_count = 3.0
nosy_names = ['rhettinger', 'paul.j3', 'ALSchwalm']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'needs patch'
status = 'open'
superseder = None
type = None
url = 'https://bugs.python.org/issue45631'
versions = []

@paulj3
Copy link
Mannequin Author

paulj3 mannequin commented Oct 27, 2021

https://bugs.python.org/issue45235
argparse does not preserve namespace with subparser defaults

was passed and put into the latest release with rather obvious buggy behavior.

This means that the unittest file does not adequately test for overlapping 'dest' in the main and subparsers. It probably also does not test many (any?) cases of user provided namespace.

bpo-9351 added a test, but it only tested defaults set with

parser.set_defaults(foo=1)
xparser.set_defaults(foo=2)

not the more common practice of setting defaults in add_argument.

45235 adds one test, but again only for

xparser.set_defaults(foo=1)

It doesn't test for user inputs, as with

['X','--foo=3']

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@AlexWaygood AlexWaygood added the tests Tests in the Lib/test dir label Apr 10, 2022
@AbhigyanBose
Copy link
Contributor

AbhigyanBose commented May 14, 2022

I'd like to fill in the missing unit tests. I'm not sure if I'd be able to find/fill up everything, I'd like to start off with listing what are the scenarios that still need to be covered. I'm not very familiar with the module, so I'd really appreciate some guidance regarding what other unit tests might be missing.

As pointed by @paulj3 I checked and I didn't find any test cases with user provided Namespaces.

Missing test cases that need to be added:

  1. Check that user provided Namespace overrides default value.
  2. Check that user provided value overrides user provided Namespace.

I obtained the above two scenarios from the discussions in https://bugs.python.org/issue45235.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir
Projects
Status: Tests
Development

No branches or pull requests

3 participants