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
e1a9b42c
Kaydet (Commit)
e1a9b42c
authored
Nis 03, 2007
tarafından
Walter Dörwald
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add tests for the filename.
Test that the stacklevel is handled correctly.
üst
8bd65000
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
test_warnings.py
Lib/test/test_warnings.py
+24
-0
warning_tests.py
Lib/test/warning_tests.py
+9
-0
No files found.
Lib/test/test_warnings.py
Dosyayı görüntüle @
e1a9b42c
...
@@ -3,6 +3,8 @@ import os
...
@@ -3,6 +3,8 @@ import os
import
unittest
import
unittest
from
test
import
test_support
from
test
import
test_support
import
warning_tests
# The warnings module isn't easily tested, because it relies on module
# The warnings module isn't easily tested, because it relies on module
# globals to store configuration information. setUp() and tearDown()
# globals to store configuration information. setUp() and tearDown()
# preserve the current settings to avoid bashing them while running tests.
# preserve the current settings to avoid bashing them while running tests.
...
@@ -97,6 +99,28 @@ class TestModule(CatchWarningTest):
...
@@ -97,6 +99,28 @@ class TestModule(CatchWarningTest):
warnings
.
_setoption
(
'error::Warning::0'
)
warnings
.
_setoption
(
'error::Warning::0'
)
self
.
assertRaises
(
UserWarning
,
warnings
.
warn
,
'convert to error'
)
self
.
assertRaises
(
UserWarning
,
warnings
.
warn
,
'convert to error'
)
def
test_filename
(
self
):
warning_tests
.
inner
(
"spam1"
)
self
.
assertEqual
(
msg
.
filename
,
"warning_tests.py"
)
warning_tests
.
outer
(
"spam2"
)
self
.
assertEqual
(
msg
.
filename
,
"warning_tests.py"
)
def
test_stacklevel
(
self
):
# Test stacklevel argument
# make sure all messages are different, so the warning won't be skipped
warning_tests
.
inner
(
"spam3"
,
stacklevel
=
1
)
self
.
assertEqual
(
msg
.
filename
,
"warning_tests.py"
)
warning_tests
.
outer
(
"spam4"
,
stacklevel
=
1
)
self
.
assertEqual
(
msg
.
filename
,
"warning_tests.py"
)
warning_tests
.
inner
(
"spam5"
,
stacklevel
=
2
)
self
.
assertEqual
(
msg
.
filename
,
"test_warnings.py"
)
warning_tests
.
outer
(
"spam6"
,
stacklevel
=
2
)
self
.
assertEqual
(
msg
.
filename
,
"warning_tests.py"
)
warning_tests
.
inner
(
"spam7"
,
stacklevel
=
9999
)
self
.
assertEqual
(
msg
.
filename
,
"sys"
)
def
test_main
(
verbose
=
None
):
def
test_main
(
verbose
=
None
):
# Obscure hack so that this test passes after reloads or repeated calls
# Obscure hack so that this test passes after reloads or repeated calls
...
...
Lib/test/warning_tests.py
0 → 100644
Dosyayı görüntüle @
e1a9b42c
# Helper module for testing the skipmodules argument of warnings.warn()
import
warnings
def
outer
(
message
,
stacklevel
=
1
):
inner
(
message
,
stacklevel
)
def
inner
(
message
,
stacklevel
=
1
):
warnings
.
warn
(
message
,
stacklevel
=
stacklevel
)
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