From 5fdf31a0cae0b4d69d41e4ff0710a1470624a752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Tue, 3 Mar 2020 03:21:42 +0000 Subject: [PATCH] Update conftest.py Signed-off-by: Bernat Gabor --- tests/unit/activation/conftest.py | 6 ++--- tests/unit/activation/test_batch.py | 40 +---------------------------- 2 files changed, 4 insertions(+), 42 deletions(-) diff --git a/tests/unit/activation/conftest.py b/tests/unit/activation/conftest.py index 08be64396..adab6142c 100644 --- a/tests/unit/activation/conftest.py +++ b/tests/unit/activation/conftest.py @@ -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 diff --git a/tests/unit/activation/test_batch.py b/tests/unit/activation/test_batch.py index 1a847b179..92b141b03 100644 --- a/tests/unit/activation/test_batch.py +++ b/tests/unit/activation/test_batch.py @@ -1,8 +1,6 @@ from __future__ import absolute_import, unicode_literals -import os import pipes -import sys from virtualenv.activation import BatchActivator @@ -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"""