Skip to content

Commit

Permalink
Add quotes to virtualenv template (conan-io#6265)
Browse files Browse the repository at this point in the history
* Add quotes to virtualenv template

Fix conan-io#6264 with required quotes

* fixing tests

Co-authored-by: James <james@conan.io>
  • Loading branch information
kmaragon and memsharded committed Feb 11, 2020
1 parent 030fa86 commit 7ec019a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions conans/client/generators/virtualenv.py
Expand Up @@ -8,7 +8,7 @@
from conans.model import Generator


sh_activate_tpl = Template(textwrap.dedent("""
sh_activate_tpl = Template(textwrap.dedent("""\
#!/usr/bin/env sh
{%- for it in modified_vars %}
Expand All @@ -20,12 +20,12 @@
export "$LINE";
done < "{{ environment_file }}"
export CONAN_OLD_PS1=$PS1
export CONAN_OLD_PS1="$PS1"
export PS1="({{venv_name}}) $PS1"
"""))

sh_deactivate_tpl = Template(textwrap.dedent("""
sh_deactivate_tpl = Template(textwrap.dedent("""\
#!/usr/bin/env sh
export PS1="$CONAN_OLD_PS1"
unset CONAN_OLD_PS1
Expand All @@ -39,7 +39,7 @@
{%- endfor %}
"""))

cmd_activate_tpl = Template(textwrap.dedent("""
cmd_activate_tpl = Template(textwrap.dedent("""\
@echo off
{%- for it in modified_vars %}
Expand All @@ -54,7 +54,7 @@
SET "PROMPT=({{venv_name}}) %PROMPT%"
"""))

cmd_deactivate_tpl = Template(textwrap.dedent("""
cmd_deactivate_tpl = Template(textwrap.dedent("""\
@echo off
SET "PROMPT=%CONAN_OLD_PROMPT%"
Expand All @@ -69,7 +69,7 @@
{%- endfor %}
"""))

ps1_activate_tpl = Template(textwrap.dedent("""
ps1_activate_tpl = Template(textwrap.dedent("""\
{%- for it in modified_vars %}
$env:CONAN_OLD_{{it}}=$env:{{it}}
{%- endfor %}
Expand All @@ -85,7 +85,7 @@
function global:prompt { write-host "({{venv_name}}) " -nonewline; & $function:_old_conan_prompt }
"""))

ps1_deactivate_tpl = Template(textwrap.dedent("""
ps1_deactivate_tpl = Template(textwrap.dedent("""\
$function:prompt = $function:_old_conan_prompt
remove-item function:_old_conan_prompt
Expand Down
2 changes: 1 addition & 1 deletion conans/test/functional/generators/virtualenv_test.py
Expand Up @@ -190,7 +190,7 @@ def _run_virtualenv(self, generator):
if platform.system() == "Linux":
ps1 = env_after.pop(six.u("PS1"), None)
if ps1:
env_after["PS1"] = ps1 + " " # TODO: FIXME: Needed for the test to pass
env_after["PS1"] = ps1 # TODO: FIXME: Needed for the test to pass
self.assertDictEqual(env_before, env_after) # Environment restored correctly

return stdout, _load_env_file(os.path.join(self.test_folder, self.env_activated))
Expand Down

0 comments on commit 7ec019a

Please sign in to comment.