From 1c888f8748f869687ec5c1753446eb86977d2a8b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 13 Sep 2024 23:20:25 +0200 Subject: [PATCH] test: fix Python 3.12 warnings about invalid escape sequences. Or maybe 3.11 warned too and I just didn't notice? --- documentation/test_doxygen/test_contents.py | 12 ++++++------ documentation/test_python/test_page.py | 2 +- plugins/m/test/test_dot.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/documentation/test_doxygen/test_contents.py b/documentation/test_doxygen/test_contents.py index 2449c144..790a654a 100644 --- a/documentation/test_doxygen/test_contents.py +++ b/documentation/test_doxygen/test_contents.py @@ -35,7 +35,7 @@ from hashlib import sha1 from . import BaseTestCase, IntegrationTestCase, doxygen_version, parse_version def dot_version(): - return re.match(".*version (?P\d+\.\d+\.\d+).*", subprocess.check_output(['dot', '-V'], stderr=subprocess.STDOUT).decode('utf-8').strip()).group('version') + return re.match(r'.*version (?P\d+\.\d+\.\d+).*', subprocess.check_output(['dot', '-V'], stderr=subprocess.STDOUT).decode('utf-8').strip()).group('version') class Typography(IntegrationTestCase): def test(self): @@ -162,7 +162,7 @@ class MathCached(IntegrationTestCase): super().__init__(*args, **kwargs) # Actually generated from $ \frac{\tau}{2} $ tho - self.tau_half_hash = sha1("""$ \pi $""".encode('utf-8')).digest() + self.tau_half_hash = sha1(r"""$ \pi $""".encode('utf-8')).digest() self.tau_half = """ @@ -177,7 +177,7 @@ class MathCached(IntegrationTestCase): """ # Actually generated from \[ a^3 + b^3 \neq c^3 \] tho - self.fermat_hash = sha1("""\[ a^2 + b^2 = c^2 \]""".encode('utf-8')).digest() + self.fermat_hash = sha1(r"""\[ a^2 + b^2 = c^2 \]""".encode('utf-8')).digest() self.fermat = """ @@ -238,7 +238,7 @@ class MathCached(IntegrationTestCase): # The file is the same expect for titles of the formulas. Replace them # and then compare. with open(os.path.join(self.path, 'html', 'math-uncached.html')) as f: - actual_contents = f.read().strip().replace('a^3 + b^3 \\neq c^3', 'a^2 + b^2 = c^2').replace('\\frac{\\tau}{2}', '\pi') + actual_contents = f.read().strip().replace(r'a^3 + b^3 \neq c^3', 'a^2 + b^2 = c^2').replace(r'\frac{\tau}{2}', r'\pi') self.assertEqual(actual_contents, expected_contents) @@ -246,9 +246,9 @@ class MathCached(IntegrationTestCase): with open(os.path.join(self.path, 'xml/math.cache'), 'rb') as f: math_cache_actual = pickle.load(f) math_cache_expected = (0, 0, { - sha1("$ \\frac{\\tau}{2} $".encode('utf-8')).digest(): + sha1('$ \frac{\tau}{2} $'.encode('utf-8')).digest(): (0, 0.344841, self.tau_half), - sha1("\\[ a^3 + b^3 \\neq c^3 \\]".encode('utf-8')).digest(): + sha1(r'\[ a^3 + b^3 \neq c^3 \]'.encode('utf-8')).digest(): (0, 0.0, self.fermat)}) self.assertEqual(math_cache_actual, math_cache_expected) diff --git a/documentation/test_python/test_page.py b/documentation/test_python/test_page.py index bf6165b4..94e9459c 100644 --- a/documentation/test_python/test_page.py +++ b/documentation/test_python/test_page.py @@ -31,7 +31,7 @@ import subprocess from . import BaseTestCase, parse_version def dot_version(): - return re.match(".*version (?P\d+\.\d+\.\d+).*", subprocess.check_output(['dot', '-V'], stderr=subprocess.STDOUT).decode('utf-8').strip()).group('version') + return re.match(r'.*version (?P\d+\.\d+\.\d+).*', subprocess.check_output(['dot', '-V'], stderr=subprocess.STDOUT).decode('utf-8').strip()).group('version') class Page(BaseTestCase): def test(self): diff --git a/plugins/m/test/test_dot.py b/plugins/m/test/test_dot.py index 48ca659c..20b1c31e 100644 --- a/plugins/m/test/test_dot.py +++ b/plugins/m/test/test_dot.py @@ -30,7 +30,7 @@ import unittest from . import PelicanPluginTestCase, parse_version def dot_version(): - return re.match(".*version (?P\d+\.\d+\.\d+).*", subprocess.check_output(['dot', '-V'], stderr=subprocess.STDOUT).decode('utf-8').strip()).group('version') + return re.match(r'.*version (?P\d+\.\d+\.\d+).*', subprocess.check_output(['dot', '-V'], stderr=subprocess.STDOUT).decode('utf-8').strip()).group('version') class Dot(PelicanPluginTestCase): def __init__(self, *args, **kwargs): -- 2.30.2