From e512b02d9bfa3ccdda9d1cde52eb85e8aa374b6b Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" Date: Sat, 20 Dec 2025 22:39:42 +0000 Subject: [PATCH 1/2] gh-142145: relax the no-longer-quadratic test timing --- Lib/test/test_minidom.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py index 7717a98583f741..fcec43e46aa60b 100644 --- a/Lib/test/test_minidom.py +++ b/Lib/test/test_minidom.py @@ -182,14 +182,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 testSetAttributeNodeWithoutOwnerDocument(self): # regression test for gh-142754 From 277b13bf579cece1f39861188f8a9e4e8c56e6d6 Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" Date: Sat, 20 Dec 2025 23:15:55 +0000 Subject: [PATCH 2/2] require cpu resource --- Lib/test/test_minidom.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py index fcec43e46aa60b..69fae957ec7fc9 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()