Skip to content

Commit a696ba8

Browse files
authored
[3.13] gh-142145: relax the no-longer-quadratic test timing (GH-143030) (#143032)
gh-142145: relax the no-longer-quadratic test timing (#143030) * gh-142145: relax the no-longer-quadratic test timing * require cpu resource (cherry picked from commit 8d2d7bb)
1 parent 86747f1 commit a696ba8

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Lib/test/test_minidom.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ def testAppendChild(self):
174174
self.assertEqual(dom.documentElement.childNodes[-1].data, "Hello")
175175
dom.unlink()
176176

177+
@support.requires_resource('cpu')
177178
def testAppendChildNoQuadraticComplexity(self):
178179
impl = getDOMImplementation()
179180

@@ -182,14 +183,18 @@ def testAppendChildNoQuadraticComplexity(self):
182183
children = [newdoc.createElement(f"child-{i}") for i in range(1, 2 ** 15 + 1)]
183184
element = top_element
184185

185-
start = time.time()
186+
start = time.monotonic()
186187
for child in children:
187188
element.appendChild(child)
188189
element = child
189-
end = time.time()
190+
end = time.monotonic()
190191

191192
# This example used to take at least 30 seconds.
192-
self.assertLess(end - start, 10)
193+
# Conservative assertion due to the wide variety of systems and
194+
# build configs timing based tests wind up run under.
195+
# A --with-address-sanitizer --with-pydebug build on a rpi5 still
196+
# completes this loop in <0.5 seconds.
197+
self.assertLess(end - start, 4)
193198

194199
def testSetAttributeNodeWithoutOwnerDocument(self):
195200
# regression test for gh-142754

0 commit comments

Comments
 (0)