@@ -382,16 +382,29 @@ def test_path_completion_doesnt_match_wildcards(request):
382382 # Currently path completion doesn't accept wildcards, so will always return empty results
383383 assert path_complete (text , line , begidx , endidx ) == []
384384
385- def test_path_completion_user_expansion ():
385+ def test_path_completion_just_tilde ():
386386 # Run path with just a tilde
387387 text = ''
388+ line = 'shell fake ~'
389+ endidx = len (line )
390+ begidx = endidx - len (text )
391+ completions_tilde = path_complete (text , line , begidx , endidx )
392+
393+ # Path complete should return a slash
394+ assert completions_tilde == [os .path .sep ]
395+
396+ def test_path_completion_user_expansion ():
397+ # Run path with a tilde and a slash
398+ text = ''
388399 if sys .platform .startswith ('win' ):
389- line = 'shell dir ~{}' . format ( text )
400+ cmd = 'dir'
390401 else :
391- line = 'shell ls ~{}' .format (text )
402+ cmd = 'ls'
403+
404+ line = 'shell {} ~{}' .format (cmd , os .path .sep )
392405 endidx = len (line )
393406 begidx = endidx - len (text )
394- completions_tilde = path_complete (text , line , begidx , endidx )
407+ completions_tilde_slash = path_complete (text , line , begidx , endidx )
395408
396409 # Run path complete on the user's home directory
397410 user_dir = os .path .expanduser ('~' )
@@ -404,7 +417,7 @@ def test_path_completion_user_expansion():
404417 completions_home = path_complete (text , line , begidx , endidx )
405418
406419 # Verify that the results are the same in both cases
407- assert completions_tilde == completions_home
420+ assert completions_tilde_slash == completions_home
408421
409422def test_path_completion_directories_only (request ):
410423 test_dir = os .path .dirname (request .module .__file__ )
0 commit comments