From a4987733c4f1fe0b4a88dad0839837eeda20a1f3 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Thu, 7 Dec 2023 23:40:23 -0800 Subject: [PATCH] Filter rl_safe_eval deprecation warning Full message eportlab/lib/rl_safe_eval.py:11: DeprecationWarning: ast.NameConstant is deprecated and will be removed in Python 3.14; use ast.Constant instead haveNameConstant = hasattr(ast,'NameConstant') Warning triggered by reportlab-4.0.7 and Python 3.12 --- tests/test_pdfinfo.py | 5 +++++ tests/test_pipeline.py | 5 +++++ tests/test_rotation.py | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/tests/test_pdfinfo.py b/tests/test_pdfinfo.py index 16cc5918..415fc193 100644 --- a/tests/test_pdfinfo.py +++ b/tests/test_pdfinfo.py @@ -4,6 +4,7 @@ from __future__ import annotations import pickle +import warnings from io import BytesIO from math import isclose @@ -20,6 +21,10 @@ from ocrmypdf.helpers import IMG2PDF_KWARGS, Resolution from ocrmypdf.pdfinfo import Colorspace, Encoding from ocrmypdf.pdfinfo.layout import PDFPage +warnings.filterwarnings( + "ignore", category=DeprecationWarning, module="reportlab.lib.rl_safe_eval" +) + # pylint: disable=protected-access diff --git a/tests/test_pipeline.py b/tests/test_pipeline.py index 9eb6a820..4eb37463 100644 --- a/tests/test_pipeline.py +++ b/tests/test_pipeline.py @@ -3,6 +3,7 @@ from __future__ import annotations +import warnings from unittest.mock import Mock import pytest @@ -14,6 +15,10 @@ from reportlab.pdfgen.canvas import Canvas from ocrmypdf import _pipeline, pdfinfo from ocrmypdf.helpers import Resolution +warnings.filterwarnings( + "ignore", category=DeprecationWarning, module="reportlab.lib.rl_safe_eval" +) + @pytest.fixture(scope='session') def rgb_image(): diff --git a/tests/test_rotation.py b/tests/test_rotation.py index c610a205..cac7e103 100644 --- a/tests/test_rotation.py +++ b/tests/test_rotation.py @@ -4,6 +4,7 @@ from __future__ import annotations import operator +import warnings from io import BytesIO from math import cos, pi, sin from os import fspath @@ -21,6 +22,10 @@ from ocrmypdf.pdfinfo import PdfInfo from .conftest import check_ocrmypdf, run_ocrmypdf_api +warnings.filterwarnings( + "ignore", category=DeprecationWarning, module="reportlab.lib.rl_safe_eval" +) + # pylintx: disable=unused-variable RENDERERS = ['hocr', 'sandwich']