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

Commit06faa9a

Browse files
authored
gh-110160: Fix flakytest_find_periodic_pattern instring_tests (#110170)
1 parent038c356 commit06faa9a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

‎Lib/test/string_tests.py‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,12 @@ def reference_find(p, s):
327327
foriinrange(len(s)):
328328
ifs.startswith(p,i):
329329
returni
330+
ifp==''ands=='':
331+
return0
330332
return-1
331333

332-
rr=random.randrange
333-
choices=random.choices
334-
for_inrange(1000):
334+
defcheck_pattern(rr):
335+
choices=random.choices
335336
p0=''.join(choices('abcde',k=rr(10)))*rr(10,20)
336337
p=p0[:len(p0)-rr(10)]# pop off some characters
337338
left=''.join(choices('abcdef',k=rr(2000)))
@@ -341,6 +342,13 @@ def reference_find(p, s):
341342
self.checkequal(reference_find(p,text),
342343
text,'find',p)
343344

345+
rr=random.randrange
346+
for_inrange(1000):
347+
check_pattern(rr)
348+
349+
# Test that empty string always work:
350+
check_pattern(lambda*args:0)
351+
344352
deftest_find_many_lengths(self):
345353
haystack_repeats= [a*10**eforeinrange(6)forain (1,2,5)]
346354
haystacks= [(n,self.fixtype("abcab"*n+"da"))forninhaystack_repeats]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp