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
6fbb96e6
Kaydet (Commit)
6fbb96e6
authored
Şub 23, 2007
tarafından
Brett Cannon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refactor PEP 352 tests to make it easier in the future to make sure certain
things cannot be raised or caught.
üst
764cf7ed
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
18 deletions
+34
-18
test_pep352.py
Lib/test/test_pep352.py
+34
-18
No files found.
Lib/test/test_pep352.py
Dosyayı görüntüle @
6fbb96e6
...
@@ -113,6 +113,37 @@ class UsageTests(unittest.TestCase):
...
@@ -113,6 +113,37 @@ class UsageTests(unittest.TestCase):
"""Test usage of exceptions"""
"""Test usage of exceptions"""
def
raise_fails
(
self
,
object_
):
"""Make sure that raising 'object_' triggers a TypeError."""
try
:
raise
object_
except
TypeError
:
return
# What is expected.
self
.
fail
(
"TypeError expected for raising
%
s"
%
type
(
object_
))
def
catch_fails
(
self
,
object_
):
"""Catching 'object_' should raise a TypeError."""
try
:
try
:
raise
StandardError
except
object_
:
pass
except
TypeError
:
pass
except
StandardError
:
self
.
fail
(
"TypeError expected when catching
%
s"
%
type
(
object_
))
try
:
try
:
raise
StandardError
except
(
object_
,):
pass
except
TypeError
:
return
except
StandardError
:
self
.
fail
(
"TypeError expected when catching
%
s as specified in a "
"tuple"
%
type
(
object_
))
def
test_raise_classic
(
self
):
def
test_raise_classic
(
self
):
# Raising a classic class is okay (for now).
# Raising a classic class is okay (for now).
class
ClassicClass
:
class
ClassicClass
:
...
@@ -137,27 +168,12 @@ class UsageTests(unittest.TestCase):
...
@@ -137,27 +168,12 @@ class UsageTests(unittest.TestCase):
# inherit from it.
# inherit from it.
class
NewStyleClass
(
object
):
class
NewStyleClass
(
object
):
pass
pass
try
:
self
.
raise_fails
(
NewStyleClass
)
raise
NewStyleClass
self
.
raise_fails
(
NewStyleClass
())
except
TypeError
:
pass
except
:
self
.
fail
(
"able to raise new-style class"
)
try
:
raise
NewStyleClass
()
except
TypeError
:
pass
except
:
self
.
fail
(
"able to raise new-style class instance"
)
def
test_raise_string
(
self
):
def
test_raise_string
(
self
):
# Raising a string raises TypeError.
# Raising a string raises TypeError.
try
:
self
.
raise_fails
(
"spam"
)
raise
"spam"
except
TypeError
:
pass
except
:
self
.
fail
(
"was able to raise a string exception"
)
def
test_catch_string
(
self
):
def
test_catch_string
(
self
):
# Catching a string should trigger a DeprecationWarning.
# Catching a string should trigger a DeprecationWarning.
...
...
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