Revision 23f41a3e testing/ganeti.utils_unittest.py

b/testing/ganeti.utils_unittest.py
151 151

  
152 152
  def testLang(self):
153 153
    """Test locale environment"""
154
    os.environ["LANG"] = "en_US.UTF-8"
155
    os.environ["LC_ALL"] = "en_US.UTF-8"
156
    result = RunCmd(["env"])
157
    for line in result.output.splitlines():
158
      key, val = line.split("=", 1)
159
      if key.startswith("LC_") or key == "LANG":
160
        self.fail("Unexpected language variable '%s' = '%s'" % (key, val))
154
    old_env = os.environ.copy()
155
    try:
156
      os.environ["LANG"] = "en_US.UTF-8"
157
      os.environ["LC_ALL"] = "en_US.UTF-8"
158
      result = RunCmd(["locale"])
159
      for line in result.output.splitlines():
160
        key, value = line.split("=", 1)
161
        # Ignore these variables, they're overridden by LC_ALL
162
        if key == "LANG" or key == "LANGUAGE":
163
          continue
164
        self.failIf(value and value != "C" and value != '"C"',
165
            "Variable %s is set to the invalid value '%s'" % (key, value))
166
    finally:
167
      os.environ = old_env
161 168

  
162 169

  
163 170
class TestRemoveFile(unittest.TestCase):

Also available in: Unified diff