Commit f6441c7c authored by Iustin Pop's avatar Iustin Pop
Browse files

Filters out LANG and LC_* on RunCmd

This filters out the LANG and LC_ variables from the environment of programs
executed by RunCmd, in order to get consistent output of execute programs like
lvs, etc.

Reviewed-by: imsnah
parent 8e587e52
......@@ -209,11 +209,13 @@ def RunCmd(cmd):
strcmd = cmd
shell = True
new_env = dict([(key, val) for (key, val) in os.environ.items()
if not (key == "LANG" or key.startswith("LC_"))])
child = subprocess.Popen(cmd, shell=shell,
close_fds=True, env=new_env)
out =
......@@ -149,6 +149,16 @@ class TestRunCmd(unittest.TestCase):
self.assertEqual(result.exit_code, 0)
self.assertEqual(result.stdout, self.magic)
def testLang(self):
"""Test locale environment"""
os.environ["LANG"] = "en_US.UTF-8"
os.environ["LC_ALL"] = "en_US.UTF-8"
result = RunCmd(["env"])
for line in result.output.splitlines():
key, val = line.split("=", 1)
if key.startswith("LC_") or key == "LANG":"Unexpected language variable '%s' = '%s'" % (key, val))
class TestRemoveFile(unittest.TestCase):
"""Test case for the RemoveFile function"""
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment