From eb8c7c3bc1ddde4e86d8da1f11e6df0dc615ddc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Thu, 2 Jan 2025 17:54:56 -0800 Subject: [PATCH] Skip tcsh tests on broken tcsh versions (#2817) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bernát Gábor --- .pre-commit-config.yaml | 2 +- docs/changelog/2814.bugfix.rst | 1 + src/virtualenv/discovery/builtin.py | 4 ++-- tests/unit/activation/conftest.py | 2 +- tests/unit/activation/test_csh.py | 14 ++++++++++++++ tests/unit/seed/wheels/test_acquire.py | 3 ++- 6 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 docs/changelog/2814.bugfix.rst diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 47b76e025..60dc868ae 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ repos: hooks: - id: pyproject-fmt - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.8.3" + rev: "v0.8.5" hooks: - id: ruff-format - id: ruff diff --git a/docs/changelog/2814.bugfix.rst b/docs/changelog/2814.bugfix.rst new file mode 100644 index 000000000..9b85df2da --- /dev/null +++ b/docs/changelog/2814.bugfix.rst @@ -0,0 +1 @@ +Skip tcsh tests on broken tcsh versions - by :user:`gaborbernat`. diff --git a/src/virtualenv/discovery/builtin.py b/src/virtualenv/discovery/builtin.py index 00c595b46..4c20832af 100644 --- a/src/virtualenv/discovery/builtin.py +++ b/src/virtualenv/discovery/builtin.py @@ -5,7 +5,7 @@ import sys from contextlib import suppress from pathlib import Path -from typing import TYPE_CHECKING, Callable +from typing import TYPE_CHECKING from virtualenv.info import IS_WIN, fs_path_id @@ -15,7 +15,7 @@ if TYPE_CHECKING: from argparse import ArgumentParser - from collections.abc import Generator, Iterable, Mapping, Sequence + from collections.abc import Callable, Generator, Iterable, Mapping, Sequence from virtualenv.app_data.base import AppData LOGGER = logging.getLogger(__name__) diff --git a/tests/unit/activation/conftest.py b/tests/unit/activation/conftest.py index 2d53d540c..1c945436d 100644 --- a/tests/unit/activation/conftest.py +++ b/tests/unit/activation/conftest.py @@ -77,7 +77,7 @@ def __call__(self, monkeypatch, tmp_path): try: process = Popen(invoke, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env) raw_, _ = process.communicate() - raw = raw_.decode() + raw = raw_.decode(errors="replace") assert process.returncode == 0, raw except subprocess.CalledProcessError as exception: output = exception.output + exception.stderr diff --git a/tests/unit/activation/test_csh.py b/tests/unit/activation/test_csh.py index 309ae811e..125ba42d4 100644 --- a/tests/unit/activation/test_csh.py +++ b/tests/unit/activation/test_csh.py @@ -1,9 +1,23 @@ from __future__ import annotations +import sys +from shutil import which +from subprocess import check_output + +import pytest +from packaging.version import Version + from virtualenv.activation import CShellActivator def test_csh(activation_tester_class, activation_tester): + exe = f"tcsh{'.exe' if sys.platform == 'win32' else ''}" + if which(exe): + version_text = check_output([exe, "--version"], text=True, encoding="utf-8") + version = Version(version_text.split(" ")[1]) + if version >= Version("6.24.14"): + pytest.skip("https://github.com/tcsh-org/tcsh/issues/117") + class Csh(activation_tester_class): def __init__(self, session) -> None: super().__init__(CShellActivator, session, "csh", "activate.csh", "csh") diff --git a/tests/unit/seed/wheels/test_acquire.py b/tests/unit/seed/wheels/test_acquire.py index 20979775b..a56480fa0 100644 --- a/tests/unit/seed/wheels/test_acquire.py +++ b/tests/unit/seed/wheels/test_acquire.py @@ -5,7 +5,7 @@ from datetime import datetime, timezone from pathlib import Path from subprocess import CalledProcessError -from typing import TYPE_CHECKING, Callable +from typing import TYPE_CHECKING import pytest @@ -16,6 +16,7 @@ from virtualenv.seed.wheels.util import Wheel, discover_wheels if TYPE_CHECKING: + from collections.abc import Callable from unittest.mock import MagicMock from pytest_mock import MockerFixture