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

addoption "--run" behaviour is inconsistent. #1146

Closed
EvanTheB opened this issue Oct 19, 2015 · 4 comments
Closed

addoption "--run" behaviour is inconsistent. #1146

EvanTheB opened this issue Oct 19, 2015 · 4 comments
Labels
status: critical grave problem or usability issue that affects lots of users status: help wanted developers would like help from experts on this topic type: backward compatibility might present some backward compatibility issues which should be carefully noted in the changelog type: bug problem that needs to be addressed

Comments

@EvanTheB
Copy link

I created an option with parser.addoption("--run")
Using this option worked find with the command line
py.test --run argument
However using the alternative syntax
py.test --run=argument
Caused the failure py.test: error: argument --runxfail: ignored explicit argument 'abc'. I assume that the option matching is using prefixes. I think the behaviour of runxfail being triggered by --run is fine, however the behaviour should be consistent between the two ways of specifying command line options.

@RonnyPfannschmidt
Copy link
Member

this seems to be a argparse bug known since 2013

@RonnyPfannschmidt RonnyPfannschmidt added type: bug problem that needs to be addressed status: help wanted developers would like help from experts on this topic type: backward compatibility might present some backward compatibility issues which should be carefully noted in the changelog status: critical grave problem or usability issue that affects lots of users labels Oct 21, 2015
@The-Compiler
Copy link
Member

What's the argparse bug? Looks fine in a quick test to me:

>>> import argparse
>>> p = argparse.ArgumentParser()
>>> p.add_argument('--run', nargs=1)
>>> p.add_argument('--runxfail')
>>> p.parse_args(['--run=foo'])
Namespace(run=['foo'], runxfail=None)
>>> p.parse_args(['--run', 'foo'])
Namespace(run=['foo'], runxfail=None)

(also, I disagree this should be marked critical)

@RonnyPfannschmidt
Copy link
Member

https://docs.python.org/2/library/argparse.html#partial-parsing

so in preparse we already kow runxfail but not run, thus runxfail is matched

@nicoddemus
Copy link
Member

Closing this in favor of #1149

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: critical grave problem or usability issue that affects lots of users status: help wanted developers would like help from experts on this topic type: backward compatibility might present some backward compatibility issues which should be carefully noted in the changelog type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

4 participants