Skip to content

Commit d9c479e

Browse files
committed
gh-142145: relax the no-longer-quadratic test timing (GH-143030)
* gh-142145: relax the no-longer-quadratic test timing * require cpu resource (cherry picked from commit 8d2d7bb) Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
1 parent 1ff4985 commit d9c479e

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
@@ -177,6 +177,7 @@ def testAppendChild(self):
177177
self.confirm(dom.documentElement.childNodes[-1].data == "Hello")
178178
dom.unlink()
179179

180+
@support.requires_resource('cpu')
180181
def testAppendChildNoQuadraticComplexity(self):
181182
impl = getDOMImplementation()
182183

@@ -185,14 +186,18 @@ def testAppendChildNoQuadraticComplexity(self):
185186
children = [newdoc.createElement(f"child-{i}") for i in range(1, 2 ** 15 + 1)]
186187
element = top_element
187188

188-
start = time.time()
189+
start = time.monotonic()
189190
for child in children:
190191
element.appendChild(child)
191192
element = child
192-
end = time.time()
193+
end = time.monotonic()
193194

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

197202
def testSetAttributeNodeWithoutOwnerDocument(self):
198203
# regression test for gh-142754

0 commit comments

Comments
 (0)