mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Merged revisions 78091,78094,78109 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r78091 | georg.brandl | 2010-02-07 19:02:22 +0200 (Sun, 07 Feb 2010) | 1 line Rename "exc_value" attribute on assertRaises context manager to "exception". ........ r78094 | michael.foord | 2010-02-07 20:44:12 +0200 (Sun, 07 Feb 2010) | 1 line assertRaises as context manager now allows you to access exception as documented ........ r78109 | ezio.melotti | 2010-02-08 23:52:08 +0200 (Mon, 08 Feb 2010) | 1 line Fix exc_value -> exception in docstring ........
This commit is contained in:
parent
7b26d7f82f
commit
4900823027
3 changed files with 20 additions and 20 deletions
|
@ -626,7 +626,6 @@ class Test_TestLoader(TestCase):
|
|||
# a good chance that it won't be imported when this test is run
|
||||
module_name = 'audioop'
|
||||
|
||||
import sys
|
||||
if module_name in sys.modules:
|
||||
del sys.modules[module_name]
|
||||
|
||||
|
@ -1014,7 +1013,6 @@ class Test_TestLoader(TestCase):
|
|||
# a good chance that it won't be imported when this test is run
|
||||
module_name = 'audioop'
|
||||
|
||||
import sys
|
||||
if module_name in sys.modules:
|
||||
del sys.modules[module_name]
|
||||
|
||||
|
@ -1972,8 +1970,6 @@ class Test_TestResult(TestCase):
|
|||
# methods. Contains formatted tracebacks instead
|
||||
# of sys.exc_info() results."
|
||||
def test_addFailure(self):
|
||||
import sys
|
||||
|
||||
class Foo(unittest.TestCase):
|
||||
def test_1(self):
|
||||
pass
|
||||
|
@ -2022,8 +2018,6 @@ class Test_TestResult(TestCase):
|
|||
# methods. Contains formatted tracebacks instead
|
||||
# of sys.exc_info() results."
|
||||
def test_addError(self):
|
||||
import sys
|
||||
|
||||
class Foo(unittest.TestCase):
|
||||
def test_1(self):
|
||||
pass
|
||||
|
@ -2861,7 +2855,7 @@ test case
|
|||
ctx = self.assertRaises(ExceptionMock)
|
||||
with ctx:
|
||||
Stub(v)
|
||||
e = ctx.exc_value
|
||||
e = ctx.exception
|
||||
self.assertIsInstance(e, ExceptionMock)
|
||||
self.assertEqual(e.args[0], v)
|
||||
|
||||
|
@ -3047,8 +3041,14 @@ class Test_Assertions(TestCase):
|
|||
pass
|
||||
else:
|
||||
self.fail("assertRaises() didn't let exception pass through")
|
||||
with self.assertRaises(KeyError):
|
||||
raise KeyError
|
||||
with self.assertRaises(KeyError) as cm:
|
||||
try:
|
||||
raise KeyError
|
||||
except Exception as e:
|
||||
exc = e
|
||||
raise
|
||||
self.assertIs(cm.exception, exc)
|
||||
|
||||
with self.assertRaises(KeyError):
|
||||
raise KeyError("key")
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue