]> granicus.if.org Git - python/commitdiff
Revert changes made to environment in test_httpservers
authorNick Coghlan <ncoghlan@gmail.com>
Sat, 17 Oct 2009 15:23:08 +0000 (15:23 +0000)
committerNick Coghlan <ncoghlan@gmail.com>
Sat, 17 Oct 2009 15:23:08 +0000 (15:23 +0000)
Lib/test/test_httpservers.py

index 228d82b64c802a0c5b70f1cca0898764cf7a9623..73354e39543f4fb7b39659e7da66fab4c45093ff 100644 (file)
@@ -50,6 +50,7 @@ class TestServerThread(threading.Thread):
 
 class BaseTestCase(unittest.TestCase):
     def setUp(self):
+        os.environ = test_support.EnvironmentVarGuard()
         self.lock = threading.Lock()
         self.thread = TestServerThread(self, self.request_handler)
         self.thread.start()
@@ -58,6 +59,8 @@ class BaseTestCase(unittest.TestCase):
     def tearDown(self):
         self.lock.release()
         self.thread.stop()
+        os.environ.__exit__()
+        os.environ = os.environ._environ
 
     def request(self, uri, method='GET', body=None, headers={}):
         self.connection = httplib.HTTPConnection('localhost', self.PORT)
@@ -390,9 +393,9 @@ def test_main(verbose=None):
     try:
         cwd = os.getcwd()
         test_support.run_unittest(BaseHTTPServerTestCase,
-                                  SimpleHTTPServerTestCase,
-                                  CGIHTTPServerTestCase
-                                  )
+                                SimpleHTTPServerTestCase,
+                                CGIHTTPServerTestCase
+                                )
     finally:
         os.chdir(cwd)