chiark / gitweb /
test: fix Python 3.12 warnings about invalid escape sequences.
authorVladimír Vondruš <mosra@centrum.cz>
Fri, 13 Sep 2024 21:20:25 +0000 (23:20 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Sat, 14 Sep 2024 00:46:33 +0000 (02:46 +0200)
Or maybe 3.11 warned too and I just didn't notice?

documentation/test_doxygen/test_contents.py
documentation/test_python/test_page.py
plugins/m/test/test_dot.py

index 2449c1449dd2c265bc65903b4f8f0f4ee1e73e77..790a654a3cfebcbcf3e9fc3f8a8e70224286e130 100644 (file)
@@ -35,7 +35,7 @@ from hashlib import sha1
 from . import BaseTestCase, IntegrationTestCase, doxygen_version, parse_version
 
 def dot_version():
-    return re.match(".*version (?P<version>\d+\.\d+\.\d+).*", subprocess.check_output(['dot', '-V'], stderr=subprocess.STDOUT).decode('utf-8').strip()).group('version')
+    return re.match(r'.*version (?P<version>\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 = """<?xml version='1.0' encoding='UTF-8'?>
 <!-- This file was generated by dvisvgm 2.6.3 -->
 <svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='5.847936pt' height='15.326665pt' viewBox='1.195514 -8.1387 4.678349 12.261332'>
@@ -177,7 +177,7 @@ class MathCached(IntegrationTestCase):
 </g>
 </svg>"""
         # 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 = """<?xml version='1.0' encoding='UTF-8'?>
 <!-- This file was generated by dvisvgm 2.6.3 -->
 <svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='75.028924pt' height='15.496355pt' viewBox='164.01086 -12.397084 60.023139 12.397084'>
@@ -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)
 
index bf6165b49894ddc44bacf499c7595095df62d0a7..94e9459c690e94a0ce1deb972619840a97a9d095 100644 (file)
@@ -31,7 +31,7 @@ import subprocess
 from . import BaseTestCase, parse_version
 
 def dot_version():
-    return re.match(".*version (?P<version>\d+\.\d+\.\d+).*", subprocess.check_output(['dot', '-V'], stderr=subprocess.STDOUT).decode('utf-8').strip()).group('version')
+    return re.match(r'.*version (?P<version>\d+\.\d+\.\d+).*', subprocess.check_output(['dot', '-V'], stderr=subprocess.STDOUT).decode('utf-8').strip()).group('version')
 
 class Page(BaseTestCase):
     def test(self):
index 48ca659cf26dd4ccebd53ecef3a149aae9eae652..20b1c31e81d74f1d59ba3dd940a39a61ba2907b4 100644 (file)
@@ -30,7 +30,7 @@ import unittest
 from . import PelicanPluginTestCase, parse_version
 
 def dot_version():
-    return re.match(".*version (?P<version>\d+\.\d+\.\d+).*", subprocess.check_output(['dot', '-V'], stderr=subprocess.STDOUT).decode('utf-8').strip()).group('version')
+    return re.match(r'.*version (?P<version>\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):