Blame 0001-test-relax-assertRaisesMsg-to-match-longer-strings.patch

73c304e
From 373b39b19d23f5dc3f5168d115297e43c4d81f8e Mon Sep 17 00:00:00 2001
73c304e
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
73c304e
Date: Tue, 26 Jan 2021 13:37:48 +0100
73c304e
Subject: [PATCH] test: relax assertRaisesMsg to match longer strings
73c304e
73c304e
With python3.10, we get the following failure:
73c304e
73c304e
======================================================================
73c304e
FAIL: test_literalname (css_parser_tests.test_property.PropertyTestCase)
73c304e
Property.literalname
73c304e
----------------------------------------------------------------------
73c304e
Traceback (most recent call last):
73c304e
  File "/builddir/build/BUILD/css-parser-1.0.6/css_parser_tests/basetest.py", line 168, in assertRaisesMsg
73c304e
    callableObj(*args, **kwargs)
73c304e
AttributeError: can't set attribute 'literalname'
73c304e
73c304e
During handling of the above exception, another exception occurred:
73c304e
73c304e
Traceback (most recent call last):
73c304e
  File "/builddir/build/BUILD/css-parser-1.0.6/css_parser_tests/test_property.py", line 165, in test_literalname
73c304e
    self.assertRaisesMsg(AttributeError, "can't set attribute", p.__setattr__,
73c304e
  File "/builddir/build/BUILD/css-parser-1.0.6/css_parser_tests/basetest.py", line 179, in assertRaisesMsg
73c304e
    raise self.failureException(
73c304e
AssertionError: Right exception, wrong message: got 'can't set attribute 'literalname'' instead of 'can't set attribute'
73c304e
73c304e
======================================================================
73c304e
FAIL: test_specificity (css_parser_tests.test_selector.SelectorTestCase)
73c304e
Selector.specificity
73c304e
----------------------------------------------------------------------
73c304e
Traceback (most recent call last):
73c304e
  File "/builddir/build/BUILD/css-parser-1.0.6/css_parser_tests/basetest.py", line 168, in assertRaisesMsg
73c304e
    callableObj(*args, **kwargs)
73c304e
  File "/builddir/build/BUILD/css-parser-1.0.6/css_parser_tests/test_selector.py", line 414, in _set
73c304e
    def _set(): selector.specificity = 1
73c304e
AttributeError: can't set attribute 'specificity'
73c304e
73c304e
During handling of the above exception, another exception occurred:
73c304e
73c304e
Traceback (most recent call last):
73c304e
  File "/builddir/build/BUILD/css-parser-1.0.6/css_parser_tests/test_selector.py", line 415, in test_specificity
73c304e
    self.assertRaisesMsg(AttributeError, "can't set attribute", _set)
73c304e
  File "/builddir/build/BUILD/css-parser-1.0.6/css_parser_tests/basetest.py", line 179, in assertRaisesMsg
73c304e
    raise self.failureException(
73c304e
AssertionError: Right exception, wrong message: got 'can't set attribute 'specificity'' instead of 'can't set attribute'
73c304e
73c304e
----------------------------------------------------------------------
73c304e
73c304e
By checking if the argument matches just a substring, we can match
73c304e
those cases without making the code more complicated. Matching just
73c304e
for substrings in exception messages is pretty common.
73c304e
---
73c304e
 css_parser_tests/basetest.py | 2 +-
73c304e
 1 file changed, 1 insertion(+), 1 deletion(-)
73c304e
73c304e
diff --git a/css_parser_tests/basetest.py b/css_parser_tests/basetest.py
73c304e
index 2b269064a1..07e8db1136 100644
73c304e
--- a/css_parser_tests/basetest.py
73c304e
+++ b/css_parser_tests/basetest.py
73c304e
@@ -171,7 +171,7 @@ class BaseTestCase(unittest.TestCase):
73c304e
             if not msg:
73c304e
                 # No message provided: any message is fine.
73c304e
                 return
73c304e
-            elif excMsg == msg:
73c304e
+            elif msg in excMsg:
73c304e
                 # Message provided, and we got the right message: passes.
73c304e
                 return
73c304e
             else: