summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-04-14 14:43:38 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-04-14 14:43:38 (GMT)
commit672559fc4f6d3811440965a12d900209f364b5f0 (patch)
tree979d08d55b6658e412461824dffa35a3cb6a6028
parent43aa0d07e2ab93bde71fb2dd5d300fef524b36cd (diff)
parent839e5eafcb351178983c2f603152091d03d60831 (diff)
downloadcpython-672559fc4f6d3811440965a12d900209f364b5f0.zip
cpython-672559fc4f6d3811440965a12d900209f364b5f0.tar.gz
cpython-672559fc4f6d3811440965a12d900209f364b5f0.tar.bz2
(Merge 3.3) Issue #17702: use assertRaises() for the unit test
-rw-r--r--Lib/test/test_os.py14
1 files changed, 4 insertions, 10 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index e6aae5c..3a38285 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -636,19 +636,13 @@ class EnvironTests(mapping_tests.BasicTestMappingProtocol):
missing = 'missingkey'
self.assertNotIn(missing, os.environ)
- try:
+ with self.assertRaises(KeyError) as cm:
os.environ[missing]
- except KeyError as err:
- self.assertIs(err.args[0], missing)
- else:
- self.fail("KeyError not raised")
+ self.assertIs(cm.exception.args[0], missing)
- try:
+ with self.assertRaises(KeyError) as cm:
del os.environ[missing]
- except KeyError as err:
- self.assertIs(err.args[0], missing)
- else:
- self.fail("KeyError not raised")
+ self.assertIs(cm.exception.args[0], missing)
class WalkTests(unittest.TestCase):
"""Tests for os.walk()."""