From a696ba8b4d42fd632afc9bc88ad830a2e4cceed8 Mon Sep 17 00:00:00 2001
From: "Gregory P. Smith" <68491+gpshead@users.noreply.github.com>
Date: Sat, 20 Dec 2025 16:22:07 -0800
Subject: [PATCH] [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)
---
 Lib/test/test_minidom.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

--- python3.10-3.10.12.orig/Lib/test/test_minidom.py
+++ python3.10-3.10.12/Lib/test/test_minidom.py
@@ -178,6 +178,7 @@ class MinidomTest(unittest.TestCase):
         self.confirm(dom.documentElement.childNodes[-1].data == "Hello")
         dom.unlink()
 
+    @support.requires_resource('cpu')
     def testAppendChildNoQuadraticComplexity(self):
         impl = getDOMImplementation()
 
@@ -186,14 +187,18 @@ class MinidomTest(unittest.TestCase):
         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, 10)
+        # 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
