Skip to content

Define test_search_anchor_at_beginning as CPU-heavy tests. #117594

@corona10

Description

@corona10

Currently test_search_anchor_at_beginning requires to be completed in an absolute time.
This can be flaky at low CPU environment or slow alternative implementation like RustPython.

I would like to suggest adding @support.requires_resource('cpu') to the test.

cpython/Lib/test/test_re.py

Lines 2285 to 2296 in 62aeb0e

def test_search_anchor_at_beginning(self):
s = 'x'*10**7
with CPUStopwatch() as stopwatch:
for p in r'\Ay', r'^y':
self.assertIsNone(re.search(p, s))
self.assertEqual(re.split(p, s), [s])
self.assertEqual(re.findall(p, s), [])
self.assertEqual(list(re.finditer(p, s)), [])
self.assertEqual(re.sub(p, '', s), s)
# Without optimization it takes 1 second on my computer.
# With optimization -- 0.0003 seconds.
self.assertLess(stopwatch.seconds, 0.1)

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dir

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions