Skip to content

Commit

Permalink
Update conftest.py
Browse files Browse the repository at this point in the history
Signed-off-by: Bernat Gabor <[email protected]>
  • Loading branch information
gaborbernat committed Mar 3, 2020
1 parent faf0ae3 commit 5fdf31a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 42 deletions.
6 changes: 3 additions & 3 deletions tests/unit/activation/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ def raise_on_non_source_class():
@pytest.fixture(scope="session", params=[True, False])
def activation_python(request, tmp_path_factory, special_char_name, current_fastest):
dest = os.path.join(ensure_text(str(tmp_path_factory.mktemp("activation-tester-env"))), special_char_name)
cmd = ["--without-pip", dest, "--creator", current_fastest, "-vv"]
if request.param:
session = cli_run(["--without-pip", dest, "--prompt", special_char_name, "--creator", current_fastest, "-vv"])
else:
session = cli_run(["--without-pip", dest, "--creator", current_fastest, "-vv"])
cmd += ["--prompt", special_char_name]
session = cli_run(cmd)
pydoc_test = session.creator.purelib / "pydoc_test.py"
pydoc_test.write_text('"""This is pydoc_test.py"""')
yield session
Expand Down
40 changes: 1 addition & 39 deletions tests/unit/activation/test_batch.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from __future__ import absolute_import, unicode_literals

import os
import pipes
import sys

from virtualenv.activation import BatchActivator

Expand All @@ -22,43 +20,7 @@ def __init__(self, session):

def _get_test_lines(self, activate_script):
# for BATCH utf-8 support need change the character code page to 650001
return [
"@echo off",
"",
"chcp 65001 1>NUL",
self.print_python_exe(),
self.print_os_env_var("PROMPT"),
self.print_os_env_var("VIRTUAL_ENV"),
self.activate_call(activate_script),
self.print_python_exe(),
self.print_os_env_var("VIRTUAL_ENV"),
# \\ loads documentation from the virtualenv site packages
self.pydoc_call,
self.print_os_env_var("PROMPT"),
self.deactivate,
self.print_python_exe(),
self.print_os_env_var("VIRTUAL_ENV"),
self.print_os_env_var("PROMPT"),
"", # just finish with an empty new line
]

def assert_output(self, out, raw, tmp_path):
# pre-activation
assert out[0], raw
assert out[2] == "None", raw
# post-activation
expected = self._creator.exe.parent / os.path.basename(sys.executable)
venv_path = self.norm_path(self._creator.dest).replace("\\\\", "\\")
assert self.norm_path(out[3]) == self.norm_path(expected), raw
assert self.norm_path(out[4]) == venv_path, raw
assert out[5] == "wrote pydoc_test.html", raw
content = tmp_path / "pydoc_test.html"
assert os.path.basename(venv_path) in out[6]
assert content.exists(), raw
# post deactivation, same as before
assert out[-3] == out[0], raw
assert out[-2] == "None", raw
assert out[1] == out[-1], raw
return ["@echo off", "", "chcp 65001 1>NUL"] + super(Batch, self)._get_test_lines(activate_script)

def quote(self, s):
"""double quotes needs to be single, and single need to be double"""
Expand Down

0 comments on commit 5fdf31a

Please sign in to comment.