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

Fix crash in FastFilesCompleter with no prefix #2750

Merged
merged 1 commit into from
Sep 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 not prefix or 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