summaryrefslogtreecommitdiff
path: root/Lib/test/test_os.py
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2007-11-01 19:08:42 +0000
committerChristian Heimes <christian@cheimes.de>2007-11-01 19:08:42 +0000
commit9033339673b0b1867cb2135767c0d70613d70ee1 (patch)
tree65b03cc554498c91faa28627de174fc5a9f0d30d /Lib/test/test_os.py
parente02647a66953bad1987daf696dc28e0dd5b2daa9 (diff)
downloadcpython-git-9033339673b0b1867cb2135767c0d70613d70ee1.tar.gz
Fixed unit tests for os.environ. Some of the tests didn't test at all because os.environ was empty.
Added import test for sys.path entries with non ASCII characters. The tests are passing on my Ubuntu box with utf-8 locales but they aren't passing on Windows XP.
Diffstat (limited to 'Lib/test/test_os.py')
-rw-r--r--Lib/test/test_os.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 0fe738264c..088101fd2b 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -191,20 +191,26 @@ from test import mapping_tests
class EnvironTests(mapping_tests.BasicTestMappingProtocol):
"""check that os.environ object conform to mapping protocol"""
type2test = None
- def _reference(self):
- return {"KEY1":"VALUE1", "KEY2":"VALUE2", "KEY3":"VALUE3"}
- def _empty_mapping(self):
- os.environ.clear()
- return os.environ
+
def setUp(self):
self.__save = dict(os.environ)
- os.environ.clear()
+ for key, value in self._reference().items():
+ os.environ[key] = value
+
def tearDown(self):
os.environ.clear()
os.environ.update(self.__save)
+ def _reference(self):
+ return {"KEY1":"VALUE1", "KEY2":"VALUE2", "KEY3":"VALUE3"}
+
+ def _empty_mapping(self):
+ os.environ.clear()
+ return os.environ
+
# Bug 1110478
def test_update2(self):
+ os.environ.clear()
if os.path.exists("/bin/sh"):
os.environ.update(HELLO="World")
value = os.popen("/bin/sh -c 'echo $HELLO'").read().strip()
@@ -217,6 +223,10 @@ class EnvironTests(mapping_tests.BasicTestMappingProtocol):
self.assertEquals(type(key), str)
self.assertEquals(type(val), str)
+ def test_items(self):
+ for key, value in self._reference().items():
+ self.assertEqual(os.environ.get(key), value)
+
class WalkTests(unittest.TestCase):
"""Tests for os.walk()."""