Following an idea by Ron Adam, make sure keys and values in the

environ dict are strings (in particular, not 8-bit strings).
This commit is contained in:
Guido van Rossum 2007-06-13 21:51:27 +00:00
parent cd16bf6404
commit 67aca9e04e
2 changed files with 14 additions and 7 deletions

View file

@ -273,6 +273,13 @@ class EnvironTests(mapping_tests.BasicTestMappingProtocol):
value = os.popen("/bin/sh -c 'echo $HELLO'").read().strip()
self.assertEquals(value, "World")
# Verify environ keys and values from the OS are of the
# correct str type.
def test_keyvalue_types(self):
for key, val in os.environ.items():
self.assertEquals(type(key), str)
self.assertEquals(type(val), str)
class WalkTests(unittest.TestCase):
"""Tests for os.walk()."""