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
def test_unknown_shell(self): vexrc = Vexrc() output = shell_config_for('unlikely_name', vexrc, {}) assert output.strip() == b''
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
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
def test_fish_config(self): vexrc = Vexrc() output = shell_config_for("fish", vexrc, {}) assert output
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
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