Skip to content

Commit

Permalink
etree: Fix XMLPullParserTest.test_flush_[..] for C version
Browse files Browse the repository at this point in the history
  • Loading branch information
hartwork committed Feb 24, 2024
1 parent 2f07457 commit 4b49de9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Lib/test/test_xml_etree.py
Original file line number Diff line number Diff line change
Expand Up @@ -1712,17 +1712,20 @@ def test_flush_reparse_deferral_enabled(self):
self.skipTest(f'Expat {pyexpat.version_info} does not support reparse deferral')

parser = ET.XMLPullParser(events=('start', 'end'))
is_python = hasattr(parser._parser, '_parser') # rather than C

for chunk in ("<doc", ">"):
parser.feed(chunk)

self.assert_event_tags(parser, []) # i.e. no elements started
self.assertTrue(parser._parser._parser.GetReparseDeferralEnabled())
if is_python:
self.assertTrue(parser._parser._parser.GetReparseDeferralEnabled())

parser.flush()

self.assert_event_tags(parser, [('start', 'doc')])
self.assertTrue(parser._parser._parser.GetReparseDeferralEnabled())
if is_python:
self.assertTrue(parser._parser._parser.GetReparseDeferralEnabled())

parser.feed("</doc>")
parser.close()
Expand All @@ -1731,6 +1734,10 @@ def test_flush_reparse_deferral_enabled(self):

def test_flush_reparse_deferral_disabled(self):
parser = ET.XMLPullParser(events=('start', 'end'))
is_python = hasattr(parser._parser, '_parser') # rather than C

if not is_python:
self.skipTest(f'XMLParser.(Get|Set)ReparseDeferralEnabled methods not available in C')

for chunk in ("<doc", ">"):
parser.feed(chunk)
Expand Down

0 comments on commit 4b49de9

Please sign in to comment.