From 4ead5c71a1e7aec611cee2d0ffda8dd3e8832948 Mon Sep 17 00:00:00 2001 From: Evan Date: Mon, 4 Sep 2017 21:40:56 +1000 Subject: [PATCH] Fix crash in FastFilesCompleter with no prefix --- _pytest/_argcomplete.py | 5 +++-- changelog/2748.bugfix | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelog/2748.bugfix diff --git a/_pytest/_argcomplete.py b/_pytest/_argcomplete.py index 1ba1ecc1e7c..5cf44267c58 100644 --- a/_pytest/_argcomplete.py +++ b/_pytest/_argcomplete.py @@ -78,7 +78,8 @@ def __call__(self, prefix, **kwargs): completion = [] globbed = [] if '*' not in prefix and '?' not in prefix: - if prefix[-1] == os.path.sep: # we are on unix, otherwise no bash + # we are on unix, otherwise no bash + if prefix and prefix[-1] == os.path.sep: globbed.extend(glob(prefix + '.*')) prefix += '*' globbed.extend(glob(prefix)) @@ -98,7 +99,7 @@ def __call__(self, prefix, **kwargs): filescompleter = FastFilesCompleter() def try_argcomplete(parser): - argcomplete.autocomplete(parser) + argcomplete.autocomplete(parser, always_complete_options=False) else: def try_argcomplete(parser): pass diff --git a/changelog/2748.bugfix b/changelog/2748.bugfix new file mode 100644 index 00000000000..b5b6f583990 --- /dev/null +++ b/changelog/2748.bugfix @@ -0,0 +1 @@ +Fix crash in tab completion when no prefix is given.