test: Ignore 'OS_' environment variables

Our functional tests are inherently dependent on 'clouds.yaml' files.
The presence of 'OS_*' environment variables can cause weird test
failures. Simply don't pass them through to our test environment.

Change-Id: I7d24cdff5f1f5798118816b12d7398b87a5f5ed4
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2023-11-14 12:20:57 +00:00
parent 900fad5360
commit e9d3a7bb13

View File

@ -30,8 +30,11 @@ def execute(cmd, *, fail_ok=False):
cmdlist = shlex.split(cmd)
stdout = subprocess.PIPE
stderr = subprocess.PIPE
env = {
k: v for k, v in os.environ.copy().items() if not k.startswith('OS_')
}
proc = subprocess.Popen(cmdlist, stdout=stdout, stderr=stderr)
proc = subprocess.Popen(cmdlist, stdout=stdout, stderr=stderr, env=env)
result_out, result_err = proc.communicate()
result_out = result_out.decode('utf-8')