mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
(Merge 3.3) Issue #17702: use assertRaises() for the unit test
This commit is contained in:
commit
672559fc4f
1 changed files with 4 additions and 10 deletions
|
|
@ -636,19 +636,13 @@ class EnvironTests(mapping_tests.BasicTestMappingProtocol):
|
||||||
missing = 'missingkey'
|
missing = 'missingkey'
|
||||||
self.assertNotIn(missing, os.environ)
|
self.assertNotIn(missing, os.environ)
|
||||||
|
|
||||||
try:
|
with self.assertRaises(KeyError) as cm:
|
||||||
os.environ[missing]
|
os.environ[missing]
|
||||||
except KeyError as err:
|
self.assertIs(cm.exception.args[0], missing)
|
||||||
self.assertIs(err.args[0], missing)
|
|
||||||
else:
|
|
||||||
self.fail("KeyError not raised")
|
|
||||||
|
|
||||||
try:
|
with self.assertRaises(KeyError) as cm:
|
||||||
del os.environ[missing]
|
del os.environ[missing]
|
||||||
except KeyError as err:
|
self.assertIs(cm.exception.args[0], missing)
|
||||||
self.assertIs(err.args[0], missing)
|
|
||||||
else:
|
|
||||||
self.fail("KeyError not raised")
|
|
||||||
|
|
||||||
class WalkTests(unittest.TestCase):
|
class WalkTests(unittest.TestCase):
|
||||||
"""Tests for os.walk()."""
|
"""Tests for os.walk()."""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue