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
77d57818
Unverified
Kaydet (Commit)
77d57818
authored
Agu 19, 2018
tarafından
Serhiy Storchaka
Kaydeden (comit)
GitHub
Agu 19, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-34318: Convert deprecation warnings to errors in assertRaises() etc. (GH-8623)
üst
e349bf23
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
19 deletions
+17
-19
case.py
Lib/unittest/case.py
+2
-7
test_case.py
Lib/unittest/test/test_case.py
+8
-12
2018-08-02-14-43-42.bpo-34318.GneiXs.rst
...S.d/next/Library/2018-08-02-14-43-42.bpo-34318.GneiXs.rst
+7
-0
No files found.
Lib/unittest/case.py
Dosyayı görüntüle @
77d57818
...
...
@@ -157,16 +157,11 @@ class _AssertRaisesBaseContext(_BaseTestCaseContext):
if
not
_is_subtype
(
self
.
expected
,
self
.
_base_type
):
raise
TypeError
(
'
%
s() arg 1 must be
%
s'
%
(
name
,
self
.
_base_type_str
))
if
args
and
args
[
0
]
is
None
:
warnings
.
warn
(
"callable is None"
,
DeprecationWarning
,
3
)
args
=
()
if
not
args
:
self
.
msg
=
kwargs
.
pop
(
'msg'
,
None
)
if
kwargs
:
warnings
.
warn
(
'
%
r is an invalid keyword argument for '
'this function'
%
next
(
iter
(
kwargs
)),
DeprecationWarning
,
3
)
raise
TypeError
(
'
%
r is an invalid keyword argument for '
'this function'
%
(
next
(
iter
(
kwargs
)),))
return
self
callable_obj
,
*
args
=
args
...
...
Lib/unittest/test/test_case.py
Dosyayı görüntüle @
77d57818
...
...
@@ -1222,7 +1222,7 @@ test case
with
self
.
assertRaises
(
self
.
failureException
):
self
.
assertRaises
(
ExceptionMock
,
lambda
:
0
)
# Failure when the function is None
with
self
.
assert
Warns
(
DeprecationWarning
):
with
self
.
assert
Raises
(
TypeError
):
self
.
assertRaises
(
ExceptionMock
,
None
)
# Failure when another exception is raised
with
self
.
assertRaises
(
ExceptionMock
):
...
...
@@ -1253,8 +1253,7 @@ test case
with
self
.
assertRaises
(
ExceptionMock
,
msg
=
'foobar'
):
pass
# Invalid keyword argument
with
self
.
assertWarnsRegex
(
DeprecationWarning
,
'foobar'
),
\
self
.
assertRaises
(
AssertionError
):
with
self
.
assertRaisesRegex
(
TypeError
,
'foobar'
):
with
self
.
assertRaises
(
ExceptionMock
,
foobar
=
42
):
pass
# Failure when another exception is raised
...
...
@@ -1295,7 +1294,7 @@ test case
self
.
assertRaisesRegex
(
ExceptionMock
,
re
.
compile
(
'expect$'
),
Stub
)
self
.
assertRaisesRegex
(
ExceptionMock
,
'expect$'
,
Stub
)
with
self
.
assert
Warns
(
DeprecationWarning
):
with
self
.
assert
Raises
(
TypeError
):
self
.
assertRaisesRegex
(
ExceptionMock
,
'expect$'
,
None
)
def
testAssertNotRaisesRegex
(
self
):
...
...
@@ -1312,8 +1311,7 @@ test case
with
self
.
assertRaisesRegex
(
Exception
,
'expect'
,
msg
=
'foobar'
):
pass
# Invalid keyword argument
with
self
.
assertWarnsRegex
(
DeprecationWarning
,
'foobar'
),
\
self
.
assertRaises
(
AssertionError
):
with
self
.
assertRaisesRegex
(
TypeError
,
'foobar'
):
with
self
.
assertRaisesRegex
(
Exception
,
'expect'
,
foobar
=
42
):
pass
...
...
@@ -1388,7 +1386,7 @@ test case
with
self
.
assertRaises
(
self
.
failureException
):
self
.
assertWarns
(
RuntimeWarning
,
lambda
:
0
)
# Failure when the function is None
with
self
.
assert
Warns
(
DeprecationWarning
):
with
self
.
assert
Raises
(
TypeError
):
self
.
assertWarns
(
RuntimeWarning
,
None
)
# Failure when another warning is triggered
with
warnings
.
catch_warnings
():
...
...
@@ -1433,8 +1431,7 @@ test case
with
self
.
assertWarns
(
RuntimeWarning
,
msg
=
'foobar'
):
pass
# Invalid keyword argument
with
self
.
assertWarnsRegex
(
DeprecationWarning
,
'foobar'
),
\
self
.
assertRaises
(
AssertionError
):
with
self
.
assertRaisesRegex
(
TypeError
,
'foobar'
):
with
self
.
assertWarns
(
RuntimeWarning
,
foobar
=
42
):
pass
# Failure when another warning is triggered
...
...
@@ -1475,7 +1472,7 @@ test case
self
.
assertWarnsRegex
(
RuntimeWarning
,
"o+"
,
lambda
:
0
)
# Failure when the function is None
with
self
.
assert
Warns
(
DeprecationWarning
):
with
self
.
assert
Raises
(
TypeError
):
self
.
assertWarnsRegex
(
RuntimeWarning
,
"o+"
,
None
)
# Failure when another warning is triggered
with
warnings
.
catch_warnings
():
...
...
@@ -1518,8 +1515,7 @@ test case
with
self
.
assertWarnsRegex
(
RuntimeWarning
,
'o+'
,
msg
=
'foobar'
):
pass
# Invalid keyword argument
with
self
.
assertWarnsRegex
(
DeprecationWarning
,
'foobar'
),
\
self
.
assertRaises
(
AssertionError
):
with
self
.
assertRaisesRegex
(
TypeError
,
'foobar'
):
with
self
.
assertWarnsRegex
(
RuntimeWarning
,
'o+'
,
foobar
=
42
):
pass
# Failure when another warning is triggered
...
...
Misc/NEWS.d/next/Library/2018-08-02-14-43-42.bpo-34318.GneiXs.rst
0 → 100644
Dosyayı görüntüle @
77d57818
:func:`~unittest.TestCase.assertRaises`,
:func:`~unittest.TestCase.assertRaisesRegex`,
:func:`~unittest.TestCase.assertWarns` and
:func:`~unittest.TestCase.assertWarnsRegex` no longer success if the passed
callable is None. They no longer ignore unknown keyword arguments in the
context manager mode. A DeprecationWarning was raised in these cases
since Python 3.5.
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