From a0196abdb52d77c635c930de78ff8d0b3f677c6a Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" <68491+gpshead@users.noreply.github.com> Date: Sat, 20 Dec 2025 15:42:06 -0800 Subject: [PATCH] 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 8d2d7bb2e754f8649a68ce4116271a4932f76907) Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com> --- Lib/test/test_minidom.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py index 4fa5a4e6768b25..3be5f2dd028acc 100644 --- a/Lib/test/test_minidom.py +++ b/Lib/test/test_minidom.py @@ -174,6 +174,7 @@ def testAppendChild(self): self.assertEqual(dom.documentElement.childNodes[-1].data, "Hello") dom.unlink() + @support.requires_resource('cpu') def testAppendChildNoQuadraticComplexity(self): impl = getDOMImplementation() @@ -182,14 +183,18 @@ def testAppendChildNoQuadraticComplexity(self): children = [newdoc.createElement(f"child-{i}") for i in range(1, 2 ** 15 + 1)] element = top_element - start = time.time() + start = time.monotonic() for child in children: element.appendChild(child) element = child - end = time.time() + end = time.monotonic() # This example used to take at least 30 seconds. - self.assertLess(end - start, 1) + # Conservative assertion due to the wide variety of systems and + # build configs timing based tests wind up run under. + # A --with-address-sanitizer --with-pydebug build on a rpi5 still + # completes this loop in <0.5 seconds. + self.assertLess(end - start, 4) def testAppendChildFragment(self): dom, orig, c1, c2, c3, frag = self._create_fragment_test_nodes()