Blob Blame History Raw
From ad79cfcb6e55837a4353b92d051de023c18f6581 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Sat, 21 May 2022 14:21:28 +0200
Subject: [PATCH 1/2] tests: adjust exception string checks for python 3.11

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2062102.
---
 css_parser_tests/test_property.py | 6 ++++--
 css_parser_tests/test_selector.py | 5 ++++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/css_parser_tests/test_property.py b/css_parser_tests/test_property.py
index ad99103..cd5a3af 100644
--- a/css_parser_tests/test_property.py
+++ b/css_parser_tests/test_property.py
@@ -5,6 +5,7 @@
 import xml.dom
 from . import basetest
 import css_parser
+import sys
 
 
 class PropertyTestCase(basetest.BaseTestCase):
@@ -162,8 +163,9 @@ def test_literalname(self):
         "Property.literalname"
         p = css_parser.css.property.Property(r'c\olor', 'red')
         self.assertEqual(r'c\olor', p.literalname)
-        self.assertRaisesMsgSubstring(AttributeError, "can't set attribute", p.__setattr__,
-                                      'literalname', 'color')
+        pattern = "object has no setter" if sys.version_info >= (3,11) else "can't set attribute"
+        self.assertRaisesMsgSubstring(AttributeError, pattern,
+                                      p.__setattr__, 'literalname', 'color')
 
     def test_validate(self):
         "Property.valid"
diff --git a/css_parser_tests/test_selector.py b/css_parser_tests/test_selector.py
index 70a9559..e6c07df 100644
--- a/css_parser_tests/test_selector.py
+++ b/css_parser_tests/test_selector.py
@@ -11,6 +11,7 @@
 import xml.dom
 from . import basetest
 import css_parser
+import sys
 
 
 class SelectorTestCase(basetest.BaseTestCase):
@@ -412,7 +413,9 @@ def test_specificity(self):
 
         # readonly
         def _set(): selector.specificity = 1
-        self.assertRaisesMsgSubstring(AttributeError, "can't set attribute", _set)
+
+        pattern = "object has no setter" if sys.version_info >= (3,11) else "can't set attribute"
+        self.assertRaisesMsgSubstring(AttributeError, pattern, _set)
 
         tests = {
             '*': (0, 0, 0, 0),

From 871cf1b64d91d53c4219c1faf14b363d05ddec05 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Sat, 21 May 2022 14:28:50 +0200
Subject: [PATCH 2/2] tests: fix warning about \( and \o being invalid
 sequences

---
 css_parser_tests/test_csscharsetrule.py | 2 +-
 css_parser_tests/test_serialize.py      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/css_parser_tests/test_csscharsetrule.py b/css_parser_tests/test_csscharsetrule.py
index cc5f347..557898c 100644
--- a/css_parser_tests/test_csscharsetrule.py
+++ b/css_parser_tests/test_csscharsetrule.py
@@ -67,7 +67,7 @@ def test_encoding(self):
         for enc in ('unknown', ):
             self.assertRaisesEx(xml.dom.SyntaxErr,
                                 self.r.__setattr__, 'encoding', enc,
-                                exc_pattern=re.compile("Unknown \(Python\) encoding"))
+                                exc_pattern=re.compile(r"Unknown \(Python\) encoding"))
 
     def test_cssText(self):
         """CSSCharsetRule.cssText
diff --git a/css_parser_tests/test_serialize.py b/css_parser_tests/test_serialize.py
index f207aea..b071f70 100644
--- a/css_parser_tests/test_serialize.py
+++ b/css_parser_tests/test_serialize.py
@@ -372,7 +372,7 @@ def test_keepAllProperties(self):
         # keep all
         css_parser.ser.prefs.keepAllProperties = True
         self.assertEqual(
-            'a {\n    color: pink;\n    color: red;\n    c\\olor: blue;\n    c\olor: green\n    }'.encode(), s.cssText)
+            'a {\n    color: pink;\n    color: red;\n    c\\olor: blue;\n    c\\olor: green\n    }'.encode(), s.cssText)
 
     def test_keepComments(self):
         "Preferences.keepComments"