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
73588542
Kaydet (Commit)
73588542
authored
Mar 18, 2010
tarafından
Florent Xicluna
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#8155: Preserve backward compatibility for test_support.check_warnings(). Add regression tests.
üst
f3e9b2a9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
15 deletions
+34
-15
test.rst
Doc/library/test.rst
+0
-0
test_support.py
Lib/test/test_support.py
+8
-3
test_warnings.py
Lib/test/test_warnings.py
+26
-12
No files found.
Doc/library/test.rst
Dosyayı görüntüle @
73588542
This diff is collapsed.
Click to expand it.
Lib/test/test_support.py
Dosyayı görüntüle @
73588542
...
...
@@ -577,14 +577,19 @@ def check_warnings(*filters, **kwargs):
Optional argument:
- if 'quiet' is True, it does not fail if a filter catches nothing
(default False)
(default True without argument,
default False if some filters are defined)
Without argument, it defaults to:
check_warnings(("", Warning), quiet=
Fals
e)
check_warnings(("", Warning), quiet=
Tru
e)
"""
quiet
=
kwargs
.
get
(
'quiet'
)
if
not
filters
:
filters
=
((
""
,
Warning
),)
return
_filterwarnings
(
filters
,
kwargs
.
get
(
'quiet'
))
# Preserve backward compatibility
if
quiet
is
None
:
quiet
=
True
return
_filterwarnings
(
filters
,
quiet
)
@contextlib.contextmanager
...
...
Lib/test/test_warnings.py
Dosyayı görüntüle @
73588542
...
...
@@ -633,19 +633,33 @@ class CatchWarningTests(BaseTest):
def
test_check_warnings
(
self
):
# Explicit tests for the test_support convenience wrapper
wmod
=
self
.
module
if
wmod
is
sys
.
modules
[
'warnings'
]:
with
test_support
.
check_warnings
()
as
w
:
self
.
assertEqual
(
w
.
warnings
,
[])
wmod
.
simplefilter
(
"always"
)
wmod
.
warn
(
"foo"
)
self
.
assertEqual
(
str
(
w
.
message
),
"foo"
)
wmod
.
warn
(
"bar"
)
self
.
assertEqual
(
str
(
w
.
message
),
"bar"
)
self
.
assertEqual
(
str
(
w
.
warnings
[
0
]
.
message
),
"foo"
)
self
.
assertEqual
(
str
(
w
.
warnings
[
1
]
.
message
),
"bar"
)
w
.
reset
()
self
.
assertEqual
(
w
.
warnings
,
[])
if
wmod
is
not
sys
.
modules
[
'warnings'
]:
return
with
test_support
.
check_warnings
(
quiet
=
False
)
as
w
:
self
.
assertEqual
(
w
.
warnings
,
[])
wmod
.
simplefilter
(
"always"
)
wmod
.
warn
(
"foo"
)
self
.
assertEqual
(
str
(
w
.
message
),
"foo"
)
wmod
.
warn
(
"bar"
)
self
.
assertEqual
(
str
(
w
.
message
),
"bar"
)
self
.
assertEqual
(
str
(
w
.
warnings
[
0
]
.
message
),
"foo"
)
self
.
assertEqual
(
str
(
w
.
warnings
[
1
]
.
message
),
"bar"
)
w
.
reset
()
self
.
assertEqual
(
w
.
warnings
,
[])
with
test_support
.
check_warnings
():
# defaults to quiet=True without argument
pass
with
test_support
.
check_warnings
((
'foo'
,
UserWarning
)):
wmod
.
warn
(
"foo"
)
with
self
.
assertRaises
(
AssertionError
):
with
test_support
.
check_warnings
((
''
,
RuntimeWarning
)):
# defaults to quiet=False with argument
pass
with
self
.
assertRaises
(
AssertionError
):
with
test_support
.
check_warnings
((
'foo'
,
RuntimeWarning
)):
wmod
.
warn
(
"foo"
)
class
CCatchWarningTests
(
CatchWarningTests
):
...
...
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