Currently, the Python scripts need a lot of set-up and tear-down code to
pass environment variables to child processes. When Hady's patch
(http://codereview.appspot.com/153042/show) is done, we can add a
parameter called update_env to gtest_test_utils.Subprocess that will let
users modify the environment being passed to Subprocess. With this
parameter, we can do away with all the SetEnvVar calls and many finally
sections in the Python tests. We will simply set update_env to set or clear
the desired env var.
An approximate code for achieving this:
def __init__(self, command, working_dir=None, capture_stderr=True,
env=None, update_env=None):
if update_env:
if env:
env = env.copy()
else:
env = os.environ.copy()
# Modifies env with values from update_env.
# None values in update_env cause deletion
# of keys in env.
for key in update_env.keys():
if update_env[key] is None and key in env:
del env[key]
else:
env[key] = update_env[key]
Original issue reported on code.google.com by vladlosev on 16 Nov 2009 at 1:55
Original issue reported on code.google.com by
vladlosev
on 16 Nov 2009 at 1:55