@@ -1,4 +1,5 @@ |
|
|
1 |
1 |
# xml.etree test for cElementTree |
|
2 |
+import io |
2 |
3 |
import struct |
3 |
4 |
from test import support |
4 |
5 |
from test.support import import_fresh_module |
@@ -133,6 +134,26 @@ def test_setstate_leaks(self): |
|
|
133 |
134 |
self.assertEqual(len(elem), 1) |
134 |
135 |
self.assertEqual(elem[0].tag, 'child') |
135 |
136 |
|
|
137 |
+def test_iterparse_leaks(self): |
|
138 |
+# Test reference leaks in TreeBuilder (issue #35502). |
|
139 |
+# The test is written to be executed in the hunting reference leaks |
|
140 |
+# mode. |
|
141 |
+XML = '' |
|
142 |
+parser = cET.iterparse(io.StringIO(XML)) |
|
143 |
+next(parser) |
|
144 |
+del parser |
|
145 |
+support.gc_collect() |
|
146 |
+ |
|
147 |
+def test_xmlpullparser_leaks(self): |
|
148 |
+# Test reference leaks in TreeBuilder (issue #35502). |
|
149 |
+# The test is written to be executed in the hunting reference leaks |
|
150 |
+# mode. |
|
151 |
+XML = '' |
|
152 |
+parser = cET.XMLPullParser() |
|
153 |
+parser.feed(XML) |
|
154 |
+del parser |
|
155 |
+support.gc_collect() |
|
156 |
+ |
136 |
157 |
|
137 |
158 |
@unittest.skipUnless(cET, 'requires _elementtree') |
138 |
159 |
class TestAliasWorking(unittest.TestCase): |