def test_as_localtime(self): now_value = timezone.now() self.assertTrue(timezone.is_aware(now_value)) self.handler.activate_locale("Europe/Madrid") new_value = timezone.as_localtime(now_value, self.handler.timezone) tzinfo = pytz.timezone("Europe/Madrid") self.assertNotEqual(new_value.tzinfo, tzinfo)
def load(self): if self._current_session_key is None: self._current_session_key = self.random_session_key() sql = session.insert().values( last_modify = timezone.now(), key = self._current_session_key, data = {} ) self.db.execute(sql) self._session_data = {} self._modified = False else: sql = select([session.c.key, session.c.data]).where(session.c.key == self._current_session_key) res_proxy = self.db.execute(sql).first() if res_proxy: self._session_data = res_proxy['data'] self._modified = False
def test_make_naive(self): dt = timezone.now() dt = timezone.make_naive(dt, pytz.timezone("Europe/Madrid")) self.assertTrue(timezone.is_naive(dt))