From 866b39179e4ce8b0ec1d38cf2d413ab872967ab7 Mon Sep 17 00:00:00 2001 From: Richard Tibbles Date: Mon, 1 Jul 2024 11:58:31 -0700 Subject: [PATCH] Remove pytest patch now that we've upgraded. --- test/patch_pytest.py | 58 ------------------------------------------ test/pytest_3.10.patch | 38 --------------------------- tox.ini | 1 - 3 files changed, 97 deletions(-) delete mode 100644 test/patch_pytest.py delete mode 100644 test/pytest_3.10.patch diff --git a/test/patch_pytest.py b/test/patch_pytest.py deleted file mode 100644 index f57e522669..0000000000 --- a/test/patch_pytest.py +++ /dev/null @@ -1,58 +0,0 @@ -""" -This script backports this Python 3.10 compatibility fix https://github.com/pytest-dev/pytest/pull/8540 -in order to allow pytest to run in Python 3.10 without upgrading to version 6.2.5 which does not support 2.7 -""" -import logging -import os -import subprocess -import sys - -import pytest - -logger = logging.getLogger(__name__) - - -def patch(): - site_packages_dir = os.path.dirname(pytest.__file__) - - patch_file = os.path.join(os.path.dirname(__file__), "pytest_3.10.patch") - - logger.info("Applying patch: " + str(patch_file)) - - # -N: insist this is FORWARD patch, don't reverse apply - # -p1: strip first path component - # -t: batch mode, don't ask questions - patch_command = [ - "patch", - "-N", - "-p1", - "-d", - site_packages_dir, - "-t", - "-i", - patch_file, - ] - logger.info(" ".join(patch_command)) - try: - # Use a dry run to establish whether the patch is already applied. - # If we don't check this, the patch may be partially applied (which is bad!) - subprocess.check_output(patch_command + ["--dry-run"]) - except subprocess.CalledProcessError as e: - if e.returncode == 1: - # Return code 1 means not all hunks could be applied, this usually - # means the patch is already applied. - logger.warning( - "Failed to apply patch (exit code 1), " - "assuming it is already applied: ", - str(patch_file), - ) - else: - raise e - else: - # The dry run worked, so do the real thing - subprocess.check_output(patch_command) - - -if __name__ == "__main__": - if sys.version_info >= (3, 10): - patch() diff --git a/test/pytest_3.10.patch b/test/pytest_3.10.patch deleted file mode 100644 index 4c933e99e6..0000000000 --- a/test/pytest_3.10.patch +++ /dev/null @@ -1,38 +0,0 @@ -diff --git a/_pytest/assertion/rewrite.py b/_pytest/assertion/rewrite.py -index 4f96b9e8c..1aa5b12de 100644 ---- a/_pytest/assertion/rewrite.py -+++ b/_pytest/assertion/rewrite.py -@@ -587,10 +587,6 @@ class AssertionRewriter(ast.NodeVisitor): - return - # Insert some special imports at the top of the module but after any - # docstrings and __future__ imports. -- aliases = [ -- ast.alias(py.builtin.builtins.__name__, "@py_builtins"), -- ast.alias("_pytest.assertion.rewrite", "@pytest_ar"), -- ] - doc = getattr(mod, "docstring", None) - expect_docstring = doc is None - if doc is not None and self.is_rewrite_disabled(doc): -@@ -617,6 +613,22 @@ class AssertionRewriter(ast.NodeVisitor): - pos += 1 - else: - lineno = item.lineno -+ # Now actually insert the special imports. -+ if sys.version_info >= (3, 10): -+ aliases = [ -+ ast.alias("builtins", "@py_builtins", lineno=lineno, col_offset=0), -+ ast.alias( -+ "_pytest.assertion.rewrite", -+ "@pytest_ar", -+ lineno=lineno, -+ col_offset=0, -+ ), -+ ] -+ else: -+ aliases = [ -+ ast.alias("builtins", "@py_builtins"), -+ ast.alias("_pytest.assertion.rewrite", "@pytest_ar"), -+ ] - imports = [ - ast.Import([alias], lineno=lineno, col_offset=0) for alias in aliases - ] diff --git a/tox.ini b/tox.ini index 011f418a10..cf1afa50e7 100644 --- a/tox.ini +++ b/tox.ini @@ -25,7 +25,6 @@ deps = -r{toxinidir}/requirements/cext.txt commands = sh -c 'kolibri manage makemigrations --check' - python test/patch_pytest.py # Run the actual tests python -O -m pytest {posargs:--cov=kolibri --cov-report= --cov-append --color=no} kolibri python -O -m pytest {posargs:--cov=kolibri --cov-report= --cov-append --color=no} -p no:django test