Make test.test_support.EnvironmentVarGuard behave like a dictionary.

All changes are mirrored to the underlying os.environ dict, but rolled back
on exit from the with block.
This commit is contained in:
Walter Dörwald 2009-05-01 17:35:37 +00:00
parent ca87fa5a5b
commit 6733bed57e
11 changed files with 72 additions and 67 deletions

View file

@ -605,7 +605,7 @@ class CGIHandlerTestCase(unittest.TestCase):
def test_cgi_get(self):
with test_support.EnvironmentVarGuard() as env:
env.set('REQUEST_METHOD', 'GET')
env['REQUEST_METHOD'] = 'GET'
# if the method is GET and no request_text is given, it runs handle_get
# get sysout output
tmp = sys.stdout
@ -646,7 +646,7 @@ class CGIHandlerTestCase(unittest.TestCase):
sys.stdout = open(test_support.TESTFN, "w")
with test_support.EnvironmentVarGuard() as env:
env.set('CONTENT_LENGTH', str(len(data)))
env['CONTENT_LENGTH'] = str(len(data))
self.cgi.handle_request()
sys.stdin.close()