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

test_path_completion_user_expansion fails when $HOME is / #171

Closed
felixonmars opened this issue Jul 5, 2017 · 5 comments · Fixed by #173
Closed

test_path_completion_user_expansion fails when $HOME is / #171

felixonmars opened this issue Jul 5, 2017 · 5 comments · Fixed by #173
Assignees
Labels
Milestone

Comments

@felixonmars
Copy link
Contributor

_____________________ test_path_completion_user_expansion ______________________

cmd2_app = <cmd2.Cmd object at 0x7f856ded3828>

    def test_path_completion_user_expansion(cmd2_app):
        # Run path with just a tilde
        text = ''
        if sys.platform.startswith('win'):
            line = '!dir ~\{}'.format(text)
        else:
            line = '!ls ~{}'.format(text)
        endidx = len(line)
        begidx = endidx - len(text)
        completions_tilde = cmd2_app.path_complete(text, line, begidx, endidx)

        # Run path complete on the user's home directory
        user_dir = os.path.expanduser('~')
        if sys.platform.startswith('win'):
            line = '!dir {}'.format(user_dir)
        else:
            line = '!ls {}'.format(user_dir)
        endidx = len(line)
        begidx = endidx - len(text)
        completions_home = cmd2_app.path_complete(text, line, begidx, endidx)

        # Verify that the results are the same in both cases
>       assert completions_tilde == completions_home
E       AssertionError: assert ['/python-cmd2/'] == ['python-cmd2/']
E         At index 0 diff: '/python-cmd2/' != 'python-cmd2/'
E         Use -v to get the full diff

tests/test_completion.py:257: AssertionError
@tleonhardt tleonhardt self-assigned this Jul 5, 2017
@tleonhardt
Copy link
Member

tleonhardt commented Jul 5, 2017

@felixonmars Could you please provide more information regarding the specific environment you encountered this problem in including:

  • OS name and version
  • Python version
  • ls version (ls --version)
  • Default shell name and version

I tested this on the following setups and was unable to reproduce the problem ( and I both tried manually exporting HOME to be "/" and hard-coding the user_dir in the unit test to be "/" just to be sure):

  • Debian 8.8 with Python 3.4 (ls from GNU coreutils version 8.23)
  • Debian 9 with Python 3.5 (ls from GNU coreutils version 8.26)
  • Debian 9 with Python 2.7 (ls from GNU coreutils version 8.26)
  • Mac OS 10.12 with Python 3.6
  • Mac OS 10.12 with Python 2.7
  • Ubuntu 16.04 with Python 3.6 (ls from GNU coreutils version 8.25)
  • Ubuntu 17.04 with Python 3.6 (ls from GNU coreutils version 8.26)
  • Ubuntu 17.04 with Python 2.7 (ls from GNU coreutils version 8.26)

For actual runtime behavior related to this, the readline library name and version is also of importance, but it shouldn't be relevant for the unit test.

What your default shell is could potentially matter as well. In all cases I tested using the default OS bash version.

@tleonhardt tleonhardt added the bug label Jul 5, 2017
@tleonhardt tleonhardt added this to the 0.7.5 milestone Jul 5, 2017
@tleonhardt
Copy link
Member

@felixonmars Thanks for the bug report!

I have now managed to reproduce the issue on my end. The problem occurs when we expand a user path and there is only a single tab-completion result. We will look into it further and work on a fix.

Thanks again for finding this subtle issue!

@tleonhardt
Copy link
Member

After looking into the issue some more, this is a bug in our unit test itself. The actual behavior at the command-line works as intended.

I will push a fix for this shortly.

@tleonhardt
Copy link
Member

@felixonmars If you can pull the last commit and test it on your end, I would appreciate it.

Thanks again!

@felixonmars
Copy link
Contributor Author

Confirmed the fix, thanks so much :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants