Skip to content

Commit

Permalink
Don't use assertRaisesRegex on Python 2.
Browse files Browse the repository at this point in the history
  • Loading branch information
hodgestar committed Aug 25, 2024
1 parent 26eda4e commit 0993bf6
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions genshi/tests/test_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -297,12 +297,15 @@ def test_convert_ElementTree_to_markup_stream(self):
def test_parsing_error(self):
text = u'<div></div>'.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():
Expand Down

0 comments on commit 0993bf6

Please sign in to comment.