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
be6caca5
Kaydet (Commit)
be6caca5
authored
Agu 19, 2015
tarafından
Robert Collins
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #20362: Honour TestCase.longMessage correctly in assertRegex.
Patch from Ilia Kurenkov.
üst
80740492
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
8 deletions
+29
-8
case.py
Lib/unittest/case.py
+11
-7
test_assertions.py
Lib/unittest/test/test_assertions.py
+14
-1
ACKS
Misc/ACKS
+1
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/unittest/case.py
Dosyayı görüntüle @
be6caca5
...
...
@@ -1279,8 +1279,10 @@ class TestCase(object):
assert
expected_regex
,
"expected_regex must not be empty."
expected_regex
=
re
.
compile
(
expected_regex
)
if
not
expected_regex
.
search
(
text
):
msg
=
msg
or
"Regex didn't match"
msg
=
'
%
s:
%
r not found in
%
r'
%
(
msg
,
expected_regex
.
pattern
,
text
)
standardMsg
=
"Regex didn't match:
%
r not found in
%
r"
%
(
expected_regex
.
pattern
,
text
)
# _formatMessage ensures the longMessage option is respected
msg
=
self
.
_formatMessage
(
msg
,
standardMsg
)
raise
self
.
failureException
(
msg
)
def
assertNotRegex
(
self
,
text
,
unexpected_regex
,
msg
=
None
):
...
...
@@ -1289,11 +1291,12 @@ class TestCase(object):
unexpected_regex
=
re
.
compile
(
unexpected_regex
)
match
=
unexpected_regex
.
search
(
text
)
if
match
:
msg
=
msg
or
"Regex matched"
msg
=
'
%
s:
%
r matches
%
r in
%
r'
%
(
msg
,
text
[
match
.
start
():
match
.
end
()],
unexpected_regex
.
pattern
,
text
)
standardMsg
=
'Regex matched:
%
r matches
%
r in
%
r'
%
(
text
[
match
.
start
()
:
match
.
end
()],
unexpected_regex
.
pattern
,
text
)
# _formatMessage ensures the longMessage option is respected
msg
=
self
.
_formatMessage
(
msg
,
standardMsg
)
raise
self
.
failureException
(
msg
)
...
...
@@ -1315,6 +1318,7 @@ class TestCase(object):
failIf
=
_deprecate
(
assertFalse
)
assertRaisesRegexp
=
_deprecate
(
assertRaisesRegex
)
assertRegexpMatches
=
_deprecate
(
assertRegex
)
assertNotRegexpMatches
=
_deprecate
(
assertNotRegex
)
...
...
Lib/unittest/test/test_assertions.py
Dosyayı görüntüle @
be6caca5
...
...
@@ -133,7 +133,6 @@ class Test_Assertions(unittest.TestCase):
try
:
self
.
assertNotRegex
(
'Ala ma kota'
,
r'k.t'
,
'Message'
)
except
self
.
failureException
as
e
:
self
.
assertIn
(
"'kot'"
,
e
.
args
[
0
])
self
.
assertIn
(
'Message'
,
e
.
args
[
0
])
else
:
self
.
fail
(
'assertNotRegex should have failed.'
)
...
...
@@ -329,6 +328,20 @@ class TestLongMessage(unittest.TestCase):
"^unexpectedly identical: None$"
,
"^unexpectedly identical: None : oops$"
])
def
testAssertRegex
(
self
):
self
.
assertMessages
(
'assertRegex'
,
(
'foo'
,
'bar'
),
[
"^Regex didn't match:"
,
"^oops$"
,
"^Regex didn't match:"
,
"^Regex didn't match: (.*) : oops$"
])
def
testAssertNotRegex
(
self
):
self
.
assertMessages
(
'assertNotRegex'
,
(
'foo'
,
'foo'
),
[
"^Regex matched:"
,
"^oops$"
,
"^Regex matched:"
,
"^Regex matched: (.*) : oops$"
])
def
assertMessagesCM
(
self
,
methodName
,
args
,
func
,
errors
):
"""
...
...
Misc/ACKS
Dosyayı görüntüle @
be6caca5
...
...
@@ -786,6 +786,7 @@ Andrew Kuchling
Dave Kuhlman
Jon Kuhn
Toshio Kuratomi
Ilia Kurenkov
Vladimir Kushnir
Erno Kuusela
Ross Lagerwall
...
...
Misc/NEWS
Dosyayı görüntüle @
be6caca5
...
...
@@ -17,6 +17,9 @@ Core and Builtins
Library
-------
- Issue #20362: Honour TestCase.longMessage correctly in assertRegex.
Patch from Ilia Kurenkov.
- Issue #24847: Removes vcruntime140.dll dependency from Tcl/Tk.
- Issue #23572: Fixed functools.singledispatch on classes with falsy
...
...
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