Esempio n. 1
0
def handle_shell_config(shell, vexrc, environ):
    """Carry out the logic of the --shell-config option.
    """
    from vex import shell_config
    data = shell_config.shell_config_for(shell, vexrc, environ)
    if not data:
        raise exceptions.OtherShell("unknown shell: {0!r}".format(shell))
    if hasattr(sys.stdout, 'buffer'):
        sys.stdout.buffer.write(data)
    else:
        sys.stdout.write(data)
    return 0
Esempio n. 2
0
def handle_shell_config(shell, vexrc, environ):
    """Carry out the logic of the --shell-config option.
    """
    from vex import shell_config
    data = shell_config.shell_config_for(shell, vexrc, environ)
    if not data:
        raise exceptions.OtherShell("unknown shell: {0!r}".format(shell))
    if hasattr(sys.stdout, 'buffer'):
        sys.stdout.buffer.write(data)
    else:
        sys.stdout.write(data)
    return 0
Esempio n. 3
0
 def test_unknown_shell(self):
     vexrc = Vexrc()
     output = shell_config_for('unlikely_name', vexrc, {})
     assert output.strip() == b''
Esempio n. 4
0
 def test_fish_config_scary(self):
     vexrc = Vexrc()
     output = shell_config_for("fish", vexrc, {'WORKON_HOME': '$x'})
     assert output
     assert b'$x' not in output
Esempio n. 5
0
 def test_fish_config_not_scary(self):
     vexrc = Vexrc()
     with patch('os.path.exists', returnvalue=True):
         output = shell_config_for("fish", vexrc, {'WORKON_HOME': '/hoorj'})
     assert output
     assert b'/hoorj' in output
Esempio n. 6
0
 def test_fish_config(self):
     vexrc = Vexrc()
     output = shell_config_for("fish", vexrc, {})
     assert output
Esempio n. 7
0
 def test_fish_config_scary(self):
     vexrc = Vexrc()
     output = shell_config_for("fish", vexrc, {"WORKON_HOME": "$x"})
     assert output
     assert b"$x" not in output
Esempio n. 8
0
 def test_fish_config_not_scary(self):
     vexrc = Vexrc()
     with patch("os.path.exists", returnvalue=True):
         output = shell_config_for("fish", vexrc, {"WORKON_HOME": "/hoorj"})
     assert output
     assert b"/hoorj" in output