diff options
Diffstat (limited to 'Lib/test/test_os.py')
-rw-r--r-- | Lib/test/test_os.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 32a67e5..e6aae5c 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -632,6 +632,24 @@ class EnvironTests(mapping_tests.BasicTestMappingProtocol): key = 'key=' self.assertRaises(OSError, os.environ.__delitem__, key) + def test_key_type(self): + missing = 'missingkey' + self.assertNotIn(missing, os.environ) + + try: + os.environ[missing] + except KeyError as err: + self.assertIs(err.args[0], missing) + else: + self.fail("KeyError not raised") + + try: + del os.environ[missing] + except KeyError as err: + self.assertIs(err.args[0], missing) + else: + self.fail("KeyError not raised") + class WalkTests(unittest.TestCase): """Tests for os.walk().""" |