mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
String exceptions are gone and so are classic classes.
This commit is contained in:
parent
28c31982eb
commit
ed483ba63b
1 changed files with 0 additions and 40 deletions
|
@ -120,22 +120,6 @@ class UsageTests(unittest.TestCase):
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
warnings.filters = self._filters[:]
|
warnings.filters = self._filters[:]
|
||||||
|
|
||||||
def test_raise_classic(self):
|
|
||||||
class ClassicClass:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
raise ClassicClass
|
|
||||||
except ClassicClass:
|
|
||||||
pass
|
|
||||||
except:
|
|
||||||
self.fail("unable to raise classic class")
|
|
||||||
try:
|
|
||||||
raise ClassicClass()
|
|
||||||
except ClassicClass:
|
|
||||||
pass
|
|
||||||
except:
|
|
||||||
self.fail("unable to raise class class instance")
|
|
||||||
|
|
||||||
def test_raise_new_style_non_exception(self):
|
def test_raise_new_style_non_exception(self):
|
||||||
class NewStyleClass(object):
|
class NewStyleClass(object):
|
||||||
pass
|
pass
|
||||||
|
@ -152,32 +136,8 @@ class UsageTests(unittest.TestCase):
|
||||||
except:
|
except:
|
||||||
self.fail("unable to raise new-style class instance")
|
self.fail("unable to raise new-style class instance")
|
||||||
|
|
||||||
def test_raise_string(self):
|
|
||||||
warnings.resetwarnings()
|
|
||||||
warnings.filterwarnings("error")
|
|
||||||
try:
|
|
||||||
raise "spam"
|
|
||||||
except DeprecationWarning:
|
|
||||||
pass
|
|
||||||
except:
|
|
||||||
self.fail("raising a string did not cause a DeprecationWarning")
|
|
||||||
|
|
||||||
def test_catch_string(self):
|
|
||||||
# Test will be pertinent when catching exceptions raises a
|
|
||||||
# DeprecationWarning
|
|
||||||
warnings.filterwarnings("ignore", "raising")
|
|
||||||
str_exc = "spam"
|
|
||||||
try:
|
|
||||||
raise str_exc
|
|
||||||
except str_exc:
|
|
||||||
pass
|
|
||||||
except:
|
|
||||||
self.fail("catching a string exception failed")
|
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
run_unittest(ExceptionClassTests, UsageTests)
|
run_unittest(ExceptionClassTests, UsageTests)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
test_main()
|
test_main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue