Revision 0f9294f7 test/ganeti.utils_unittest.py

b/test/ganeti.utils_unittest.py
1713 1713
    FormatTime(int(time.time()))
1714 1714

  
1715 1715

  
1716
class TestFormatTimestampWithTZ(unittest.TestCase):
1717
  @staticmethod
1718
  def _TestInProcess(tz, timestamp, expected):
1719
    os.environ["TZ"] = tz
1720
    time.tzset()
1721
    return utils.FormatTimestampWithTZ(timestamp) == expected
1722

  
1723
  def _Test(self, *args):
1724
    # Need to use separate process as we want to change TZ
1725
    self.assert_(utils.RunInSeparateProcess(self._TestInProcess, *args))
1726

  
1727
  def test(self):
1728
    self._Test("UTC", 0, "1970-01-01 00:00:00 UTC")
1729
    self._Test("America/Sao_Paulo", 1292606926, "2010-12-17 15:28:46 BRST")
1730
    self._Test("Europe/London", 1292606926, "2010-12-17 17:28:46 GMT")
1731
    self._Test("Europe/Zurich", 1292606926, "2010-12-17 18:28:46 CET")
1732
    self._Test("Australia/Sydney", 1292606926, "2010-12-18 04:28:46 EST")
1733

  
1734

  
1735 1716
class RunInSeparateProcess(unittest.TestCase):
1736 1717
  def test(self):
1737 1718
    for exp in [True, False]:

Also available in: Unified diff