def test_shift(self): """Test when.shift()""" first = when.shift(self.utc, from_tz='UTC', to_tz='America/New_York') second = when.shift(first, from_tz='America/New_York', to_tz='UTC') self.assertNotEqual(first, second) self.assertNotEqual(first, self.utc) self.assertEqual(second, self.utc) # Local time if self.timezone == 'UTC': # This block is needed for tests run in an environment set to UTC. first = when.shift(self.now, to_tz='America/New_York') second = when.shift(first, from_tz='America/New_York') else: first = when.shift(self.now, to_tz='UTC') second = when.shift(first, from_tz='UTC') self.assertNotEqual(first, second) self.assertNotEqual(first, self.now) self.assertEqual(second, self.now) # Set utc parameter to true first = when.shift(self.utc, to_tz='America/New_York', utc=True) second = when.shift(first, from_tz='America/New_York', utc=True) self.assertNotEqual(first, second) self.assertNotEqual(first, self.utc) self.assertEqual(second, self.utc) # Force UTC when.set_utc() first = when.shift(self.utc, to_tz='America/New_York') second = when.shift(first, from_tz='America/New_York') self.assertNotEqual(first, second) self.assertNotEqual(first, self.utc) self.assertEqual(second, self.utc)
def test_set_utc(self): when.set_utc() self.assertEqual(when._FORCE_UTC, True)
def test_set_utc(self): """Test when.set_utc()""" when.set_utc() self.assertEqual(when._FORCE_UTC, True)