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
8ae9ce5e
Kaydet (Commit)
8ae9ce5e
authored
Agu 18, 2000
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Better conformance to the Python Style Guide: use spaces around operators.
üst
fe5c22a8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
32 deletions
+33
-32
test_re.py
Lib/test/test_re.py
+33
-32
No files found.
Lib/test/test_re.py
Dosyayı görüntüle @
8ae9ce5e
import
sys
import
sys
sys
.
path
=
[
'.'
]
+
sys
.
path
sys
.
path
=
[
'.'
]
+
sys
.
path
from
test_support
import
verbose
,
TestFailed
from
test_support
import
verbose
,
TestFailed
import
re
import
re
...
@@ -270,18 +270,18 @@ else:
...
@@ -270,18 +270,18 @@ else:
for
t
in
tests
:
for
t
in
tests
:
sys
.
stdout
.
flush
()
sys
.
stdout
.
flush
()
pattern
=
s
=
outcome
=
repl
=
expected
=
None
pattern
=
s
=
outcome
=
repl
=
expected
=
None
if
len
(
t
)
==
5
:
if
len
(
t
)
==
5
:
pattern
,
s
,
outcome
,
repl
,
expected
=
t
pattern
,
s
,
outcome
,
repl
,
expected
=
t
elif
len
(
t
)
==
3
:
elif
len
(
t
)
==
3
:
pattern
,
s
,
outcome
=
t
pattern
,
s
,
outcome
=
t
else
:
else
:
raise
ValueError
,
(
'Test tuples should have 3 or 5 fields'
,
t
)
raise
ValueError
,
(
'Test tuples should have 3 or 5 fields'
,
t
)
try
:
try
:
obj
=
re
.
compile
(
pattern
)
obj
=
re
.
compile
(
pattern
)
except
re
.
error
:
except
re
.
error
:
if
outcome
==
SYNTAX_ERROR
:
pass
# Expected a syntax error
if
outcome
==
SYNTAX_ERROR
:
pass
# Expected a syntax error
else
:
else
:
print
'=== Syntax error:'
,
t
print
'=== Syntax error:'
,
t
except
KeyboardInterrupt
:
raise
KeyboardInterrupt
except
KeyboardInterrupt
:
raise
KeyboardInterrupt
...
@@ -291,16 +291,16 @@ for t in tests:
...
@@ -291,16 +291,16 @@ for t in tests:
traceback
.
print_exc
(
file
=
sys
.
stdout
)
traceback
.
print_exc
(
file
=
sys
.
stdout
)
else
:
else
:
try
:
try
:
result
=
obj
.
search
(
s
)
result
=
obj
.
search
(
s
)
except
(
re
.
error
)
,
msg
:
except
re
.
error
,
msg
:
print
'=== Unexpected exception'
,
t
,
repr
(
msg
)
print
'=== Unexpected exception'
,
t
,
repr
(
msg
)
if
outcome
==
SYNTAX_ERROR
:
if
outcome
==
SYNTAX_ERROR
:
# This should have been a syntax error; forget it.
# This should have been a syntax error; forget it.
pass
pass
elif
outcome
==
FAIL
:
elif
outcome
==
FAIL
:
if
result
is
None
:
pass
# No match, as expected
if
result
is
None
:
pass
# No match, as expected
else
:
print
'=== Succeeded incorrectly'
,
t
else
:
print
'=== Succeeded incorrectly'
,
t
elif
outcome
==
SUCCEED
:
elif
outcome
==
SUCCEED
:
if
result
is
not
None
:
if
result
is
not
None
:
# Matched, as expected, so now we compute the
# Matched, as expected, so now we compute the
# result string and compare it to our expected result.
# result string and compare it to our expected result.
...
@@ -325,24 +325,24 @@ for t in tests:
...
@@ -325,24 +325,24 @@ for t in tests:
except
IndexError
:
except
IndexError
:
gi
=
"Error"
gi
=
"Error"
vardict
[
i
]
=
gi
vardict
[
i
]
=
gi
repl
=
eval
(
repl
,
vardict
)
repl
=
eval
(
repl
,
vardict
)
if
repl
!=
expected
:
if
repl
!=
expected
:
print
'=== grouping error'
,
t
,
print
'=== grouping error'
,
t
,
print
repr
(
repl
)
+
' should be '
+
repr
(
expected
)
print
repr
(
repl
)
+
' should be '
+
repr
(
expected
)
else
:
else
:
print
'=== Failed incorrectly'
,
t
print
'=== Failed incorrectly'
,
t
# Try the match on a unicode string, and check that it
# Try the match on a unicode string, and check that it
# still succeeds.
# still succeeds.
result
=
obj
.
search
(
unicode
(
s
,
"latin-1"
))
result
=
obj
.
search
(
unicode
(
s
,
"latin-1"
))
if
result
==
None
:
if
result
==
None
:
print
'=== Fails on unicode match'
,
t
print
'=== Fails on unicode match'
,
t
# Try the match on a unicode pattern, and check that it
# Try the match on a unicode pattern, and check that it
# still succeeds.
# still succeeds.
obj
=
re
.
compile
(
unicode
(
pattern
,
"latin-1"
))
obj
=
re
.
compile
(
unicode
(
pattern
,
"latin-1"
))
result
=
obj
.
search
(
s
)
result
=
obj
.
search
(
s
)
if
result
==
None
:
if
result
==
None
:
print
'=== Fails on unicode pattern match'
,
t
print
'=== Fails on unicode pattern match'
,
t
# Try the match with the search area limited to the extent
# Try the match with the search area limited to the extent
...
@@ -350,29 +350,30 @@ for t in tests:
...
@@ -350,29 +350,30 @@ for t in tests:
# break (because it won't match at the end or start of a
# break (because it won't match at the end or start of a
# string), so we'll ignore patterns that feature it.
# string), so we'll ignore patterns that feature it.
if
pattern
[:
2
]
!=
'
\\
B'
and
pattern
[
-
2
:]
!=
'
\\
B'
and
result
!=
None
:
if
pattern
[:
2
]
!=
'
\\
B'
and
pattern
[
-
2
:]
!=
'
\\
B'
\
obj
=
re
.
compile
(
pattern
)
and
result
!=
None
:
result
=
obj
.
search
(
s
,
result
.
start
(
0
),
result
.
end
(
0
)
+
1
)
obj
=
re
.
compile
(
pattern
)
if
result
==
None
:
result
=
obj
.
search
(
s
,
result
.
start
(
0
),
result
.
end
(
0
)
+
1
)
if
result
==
None
:
print
'=== Failed on range-limited match'
,
t
print
'=== Failed on range-limited match'
,
t
# Try the match with IGNORECASE enabled, and check that it
# Try the match with IGNORECASE enabled, and check that it
# still succeeds.
# still succeeds.
obj
=
re
.
compile
(
pattern
,
re
.
IGNORECASE
)
obj
=
re
.
compile
(
pattern
,
re
.
IGNORECASE
)
result
=
obj
.
search
(
s
)
result
=
obj
.
search
(
s
)
if
result
==
None
:
if
result
==
None
:
print
'=== Fails on case-insensitive match'
,
t
print
'=== Fails on case-insensitive match'
,
t
# Try the match with LOCALE enabled, and check that it
# Try the match with LOCALE enabled, and check that it
# still succeeds.
# still succeeds.
obj
=
re
.
compile
(
pattern
,
re
.
LOCALE
)
obj
=
re
.
compile
(
pattern
,
re
.
LOCALE
)
result
=
obj
.
search
(
s
)
result
=
obj
.
search
(
s
)
if
result
==
None
:
if
result
==
None
:
print
'=== Fails on locale-sensitive match'
,
t
print
'=== Fails on locale-sensitive match'
,
t
# Try the match with UNICODE locale enabled, and check
# Try the match with UNICODE locale enabled, and check
# that it still succeeds.
# that it still succeeds.
obj
=
re
.
compile
(
pattern
,
re
.
UNICODE
)
obj
=
re
.
compile
(
pattern
,
re
.
UNICODE
)
result
=
obj
.
search
(
s
)
result
=
obj
.
search
(
s
)
if
result
==
None
:
if
result
==
None
:
print
'=== Fails on unicode-sensitive match'
,
t
print
'=== Fails on unicode-sensitive match'
,
t
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