marcwebbie / passpie

:closed_lock_with_key: Multiplatform command-line password manager
http://passpie.readthedocs.org/
MIT License
921 stars 68 forks source link

Update completion.py #50

Closed cs09g closed 9 years ago

cs09g commented 9 years ago

variable SHELLS is used in somewhere?

If not, there will be better way to remove duplication of the code using SHELLS's index.

landscape-bot commented 9 years ago

Code Health Code quality remained the same when pulling 41934d5 on cs09g:patch-1 into 3fc928e on marcwebbie:master.

marcwebbie commented 9 years ago

Hello @cs09g. thanks for your contribution. This pull request is failing on CI:

=================================== FAILURES ===================================
______________ test_script_returns_zsh_script_when_zsh_shell_name ______________
mocker = <pytest_mock.MockFixture object at 0x7f0ba111e320>
    def test_script_returns_zsh_script_when_zsh_shell_name(mocker):
        shell_name = 'zsh'
        config_path = '/tmp'
        commands = ['add', 'remove', 'update', 'remove']
        text = completion.script(shell_name=shell_name,
                                 config_path=config_path,
                                 commands=commands)

        for line in completion.ZSH.split('\n')[:3]:
>           assert line in text
E           assert 'if [[ ! -o interactive ]]; then' in 'ZSH'
tests/test_completion.py:13: AssertionError

_____________ test_script_returns_bash_script_when_bash_shell_name _____________
mocker = <pytest_mock.MockFixture object at 0x7f0ba1100dd8>
    def test_script_returns_bash_script_when_bash_shell_name(mocker):
        shell_name = 'bash'
        config_path = '/tmp'
        commands = ['add', 'remove', 'update', 'remove']
        text = completion.script(shell_name=shell_name,
                                 config_path=config_path,
                                 commands=commands)

        for line in completion.BASH.split('\n')[:3]:
>           assert line in text
E           assert 'function _passpie()' in 'BASH'
cs09g commented 9 years ago

Oh, sorry. Now, I understand that 'BASH' and 'ZSH' are global variables. pair = {shell_name : globals()[shell_name.upper()]} will be the solution.