Skip to content

Commit 63673f9

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 335454d commit 63673f9

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

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

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

189-
start = time.time()
190+
start = time.monotonic()
190191
for child in children:
191192
element.appendChild(child)
192193
element = child
193-
end = time.time()
194+
end = time.monotonic()
194195

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

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

0 commit comments

Comments
 (0)