Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[3.11] gh-110160: Fix flakytest_find_periodic_pattern instring_tests (…#110183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-110160: Fix flakytest_find_periodic_pattern instring_tests (#…
…110170)(cherry picked from commit06faa9a)
  • Loading branch information
@sobolevn@vstinner
sobolevn authored andvstinner committedOct 1, 2023
commit85d25a8d79f16019b6da9b8a3a5f95a95b67fc03
14 changes: 11 additions & 3 deletionsLib/test/string_tests.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -327,11 +327,12 @@ def reference_find(p, s):
for i in range(len(s)):
if s.startswith(p, i):
return i
if p == '' and s == '':
return 0
return -1

rr = random.randrange
choices = random.choices
for _ in range(1000):
def check_pattern(rr):
choices = random.choices
p0 = ''.join(choices('abcde', k=rr(10))) * rr(10, 20)
p = p0[:len(p0) - rr(10)] # pop off some characters
left = ''.join(choices('abcdef', k=rr(2000)))
Expand All@@ -341,6 +342,13 @@ def reference_find(p, s):
self.checkequal(reference_find(p, text),
text, 'find', p)

rr = random.randrange
for _ in range(1000):
check_pattern(rr)

# Test that empty string always work:
check_pattern(lambda *args: 0)

def test_find_shift_table_overflow(self):
"""When the table of 8-bit shifts overflows."""
N = 2**8 + 100
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp