Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
5ba0054e
Kaydet (Commit)
5ba0054e
authored
Nis 25, 2003
tarafından
Skip Montanaro
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
final bit of tests converted from test_sre
üst
9593792d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
8 deletions
+25
-8
test_re.py
Lib/test/test_re.py
+25
-8
No files found.
Lib/test/test_re.py
Dosyayı görüntüle @
5ba0054e
...
...
@@ -16,12 +16,12 @@ class ReTests(unittest.TestCase):
self
.
assertEqual
(
re
.
search
(
'x*'
,
'axx'
)
.
span
(),
(
0
,
0
))
self
.
assertEqual
(
re
.
search
(
'x+'
,
'axx'
)
.
span
(
0
),
(
1
,
3
))
self
.
assertEqual
(
re
.
search
(
'x+'
,
'axx'
)
.
span
(),
(
1
,
3
))
self
.
assertEqual
(
re
.
search
(
'x'
,
'aaa'
)
is
None
,
Tru
e
)
self
.
assertEqual
(
re
.
search
(
'x'
,
'aaa'
)
,
Non
e
)
self
.
assertEqual
(
re
.
match
(
'a*'
,
'xxx'
)
.
span
(
0
),
(
0
,
0
))
self
.
assertEqual
(
re
.
match
(
'a*'
,
'xxx'
)
.
span
(),
(
0
,
0
))
self
.
assertEqual
(
re
.
match
(
'x*'
,
'xxxa'
)
.
span
(
0
),
(
0
,
3
))
self
.
assertEqual
(
re
.
match
(
'x*'
,
'xxxa'
)
.
span
(),
(
0
,
3
))
self
.
assertEqual
(
re
.
match
(
'a+'
,
'xxx'
)
is
None
,
Tru
e
)
self
.
assertEqual
(
re
.
match
(
'a+'
,
'xxx'
)
,
Non
e
)
def
bump_num
(
self
,
matchobj
):
int_value
=
int
(
matchobj
.
group
(
0
))
...
...
@@ -133,13 +133,16 @@ class ReTests(unittest.TestCase):
(
":"
,
":"
),
(
":"
,
"::"
)])
def
test_bug_117612
(
self
):
self
.
assertEqual
(
re
.
findall
(
r"(a|(b))"
,
"aba"
),
[(
"a"
,
""
),(
"b"
,
"b"
),(
"a"
,
""
)])
def
test_re_match
(
self
):
# No groups at all
m
=
re
.
match
(
'a'
,
'a'
)
self
.
assertEqual
(
m
.
groups
(),
())
# A single group
m
=
re
.
match
(
'(a)'
,
'a'
)
self
.
assertEqual
(
m
.
groups
(),
(
'a'
,))
self
.
assertEqual
(
re
.
match
(
'a'
,
'a'
)
.
groups
(),
())
self
.
assertEqual
(
re
.
match
(
'(a)'
,
'a'
)
.
groups
(),
(
'a'
,))
self
.
assertEqual
(
re
.
match
(
r'(a)'
,
'a'
)
.
group
(
0
),
'a'
)
self
.
assertEqual
(
re
.
match
(
r'(a)'
,
'a'
)
.
group
(
1
),
'a'
)
self
.
assertEqual
(
re
.
match
(
r'(a)'
,
'a'
)
.
group
(
1
,
1
),
(
'a'
,
'a'
))
pat
=
re
.
compile
(
'((a)|(b))(c)?'
)
self
.
assertEqual
(
pat
.
match
(
'a'
)
.
groups
(),
(
'a'
,
'a'
,
None
,
None
))
...
...
@@ -264,6 +267,20 @@ class ReTests(unittest.TestCase):
([
'sum'
,
'op='
,
3
,
'op*'
,
'foo'
,
'op+'
,
312.5
,
'op+'
,
'bar'
],
''
))
def
test_bug_448951
(
self
):
# bug 448951 (similar to 429357, but with single char match)
# (Also test greedy matches.)
for
op
in
''
,
'?'
,
'*'
:
self
.
assertEqual
(
re
.
match
(
r'((.
%
s):)?z'
%
op
,
'z'
)
.
groups
(),
(
None
,
None
))
self
.
assertEqual
(
re
.
match
(
r'((.
%
s):)?z'
%
op
,
'a:z'
)
.
groups
(),
(
'a:'
,
'a'
))
def
test_finditer
(
self
):
iter
=
re
.
finditer
(
r":+"
,
"a:b::c:::d"
)
self
.
assertEqual
([
item
.
group
(
0
)
for
item
in
iter
],
[
":"
,
"::"
,
":::"
])
def
run_re_tests
():
from
test.re_tests
import
benchmarks
,
tests
,
SUCCEED
,
FAIL
,
SYNTAX_ERROR
if
verbose
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment