From 238036c0fb9ed1b550edd87f2cd255f0c530030d Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Sun, 7 Apr 2024 15:11:03 +0900 Subject: [PATCH 1/2] gh-117594: Requre cpu resource to test_search_anchor_at_beginning --- Lib/test/test_re.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index b1ac22c28cf7c1..6a72b1782167e7 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -1,7 +1,7 @@ from test.support import (gc_collect, bigmemtest, _2G, cpython_only, captured_stdout, check_disallow_instantiation, is_emscripten, is_wasi, - warnings_helper, SHORT_TIMEOUT, CPUStopwatch) + warnings_helper, SHORT_TIMEOUT, CPUStopwatch, requires_resource) import locale import re import string @@ -2282,6 +2282,7 @@ def test_bug_40736(self): with self.assertRaisesRegex(TypeError, "got 'type'"): re.search("x*", type) + @requires_resource('cpu') def test_search_anchor_at_beginning(self): s = 'x'*10**7 with CPUStopwatch() as stopwatch: From 6543871579cd5ca571346762d8c49d23f89efb73 Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Mon, 8 Apr 2024 08:30:03 +0900 Subject: [PATCH 2/2] Address code review --- Lib/test/test_re.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index 6a72b1782167e7..b8b50e8b3c2190 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -2282,6 +2282,8 @@ def test_bug_40736(self): with self.assertRaisesRegex(TypeError, "got 'type'"): re.search("x*", type) + # gh-117594: The test is not slow by itself, but it relies on + # the absolute computation time and can fail on very slow computers. @requires_resource('cpu') def test_search_anchor_at_beginning(self): s = 'x'*10**7