Skip to content

Commit

Permalink
Do not allow abbreviated arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Jun 22, 2019
1 parent 4f57d40 commit 91b100f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions changelog/1149.feature.rst
@@ -0,0 +1,4 @@
Pytest no longer accepts prefixes of command-line arguments.
This was previously allowed where the ``ArgumentParser`` thought it was unambigious,
because this could be incorrect due to delayed parsing of options for plugins.
See for example issues #1149, #3413, and #4009.
2 changes: 1 addition & 1 deletion extra/get_issues.py
Expand Up @@ -74,7 +74,7 @@ def report(issues):
if __name__ == "__main__":
import argparse

parser = argparse.ArgumentParser("process bitbucket issues")
parser = argparse.ArgumentParser("process bitbucket issues", allow_abbrev=False)
parser.add_argument(
"--refresh", action="store_true", help="invalidate cache, refresh issues"
)
Expand Down
2 changes: 1 addition & 1 deletion scripts/release.py
Expand Up @@ -105,7 +105,7 @@ def changelog(version, write_out=False):

def main():
init(autoreset=True)
parser = argparse.ArgumentParser()
parser = argparse.ArgumentParser(allow_abbrev=False)
parser.add_argument("version", help="Release version")
options = parser.parse_args()
pre_release(options.version)
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/config/argparsing.py
Expand Up @@ -328,6 +328,7 @@ def __init__(self, parser, extra_info=None, prog=None):
usage=parser._usage,
add_help=False,
formatter_class=DropShorterLongHelpFormatter,
allow_abbrev=False,
)
# extra_info is a dict of (param -> value) to display if there's
# an usage error to provide more contextual information to the user
Expand Down
Expand Up @@ -4,7 +4,7 @@
HERE = pathlib.Path(__file__).parent
TEST_CONTENT = (HERE / "template_test.py").read_bytes()

parser = argparse.ArgumentParser()
parser = argparse.ArgumentParser(allow_abbrev=False)
parser.add_argument("numbers", nargs="*", type=int)


Expand Down
2 changes: 1 addition & 1 deletion testing/test_parseopt.py
Expand Up @@ -200,7 +200,7 @@ def defaultget(option):

def test_drop_short_helper(self):
parser = argparse.ArgumentParser(
formatter_class=parseopt.DropShorterLongHelpFormatter
formatter_class=parseopt.DropShorterLongHelpFormatter, allow_abbrev=False
)
parser.add_argument(
"-t", "--twoword", "--duo", "--two-word", "--two", help="foo"
Expand Down

0 comments on commit 91b100f

Please sign in to comment.