Skip to content

Commit

Permalink
Fix crash in FastFilesCompleter with no prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
evanunderscore committed Sep 7, 2017
1 parent 549f5c1 commit 7765384
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions _pytest/_argcomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions changelog/2748.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix crash in tab completion when no prefix is given.
2 changes: 1 addition & 1 deletion testing/test_argcomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def test_compare_with_compgen(self):
from _pytest._argcomplete import FastFilesCompleter
ffc = FastFilesCompleter()
fc = FilesCompleter()
for x in '/ /d /data qqq'.split():
for x in ['/', '/d', '/data', 'qqq', '']:
assert equal_with_bash(x, ffc, fc, out=py.std.sys.stdout)

@pytest.mark.skipif("sys.platform in ('win32', 'darwin')")
Expand Down

0 comments on commit 7765384

Please sign in to comment.