From 0993bf649fe1053abe94d495a7c501921345721b Mon Sep 17 00:00:00 2001 From: Simon Cross Date: Sun, 25 Aug 2024 13:03:09 +0200 Subject: [PATCH] Don't use assertRaisesRegex on Python 2. --- genshi/tests/test_input.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/genshi/tests/test_input.py b/genshi/tests/test_input.py index 28840d0..e68515d 100644 --- a/genshi/tests/test_input.py +++ b/genshi/tests/test_input.py @@ -15,7 +15,7 @@ from genshi.core import Attrs, QName, Stream from genshi.input import XMLParser, HTMLParser, ParseError, ET -from genshi.compat import StringIO, BytesIO +from genshi.compat import IS_PYTHON2, StringIO, BytesIO from genshi.tests.utils import doctest_suite from xml.etree import ElementTree @@ -297,12 +297,15 @@ def test_convert_ElementTree_to_markup_stream(self): def test_parsing_error(self): text = u'
'.encode('utf-8') events = HTMLParser(BytesIO(text)) - self.assertRaisesRegex( - ParseError, - r"source returned bytes, but no encoding specified", - list, - events, - ) + if IS_PYTHON2: + self.assertRaises(ParseError, list, events) + else: + self.assertRaisesRegex( + ParseError, + r"source returned bytes, but no encoding specified", + list, + events, + ) def suite():