Skip to content

test_path_completion_user_expansion fails when $HOME is / #171

@felixonmars

Description

@felixonmars
_____________________ 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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions