當前位置: 首頁>>代碼示例>>Python>>正文


Python IkaUtils.getTime方法代碼示例

本文整理匯總了Python中ikalog.utils.IkaUtils.getTime方法的典型用法代碼示例。如果您正苦於以下問題:Python IkaUtils.getTime方法的具體用法?Python IkaUtils.getTime怎麽用?Python IkaUtils.getTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ikalog.utils.IkaUtils的用法示例。


在下文中一共展示了IkaUtils.getTime方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_get_time

# 需要導入模塊: from ikalog.utils import IkaUtils [as 別名]
# 或者: from ikalog.utils.IkaUtils import getTime [as 別名]
    def test_get_time(self):
        mock_context = {'engine': {'epoch_time': None, 'msec': 5000}}

        # epoch_time is None
        time_before = time.time()
        time_actual = IkaUtils.getTime(mock_context)
        time_after = time.time()
        self.assertTrue(time_before <= time_actual <= time_after)

        # epoch_time is 0
        mock_context['engine']['epoch_time'] = 0
        expected_time = (mock_context['engine']['epoch_time'] +
                         mock_context['engine']['msec'] / 1000.0)
        self.assertEqual(expected_time, IkaUtils.getTime(mock_context))

        # epoch_time is 2015-05-28 10:00:00, msec is 1 hour
        mock_context['engine']['epoch_time'] = (
            time.mktime(time.strptime("20150528_100000", "%Y%m%d_%H%M%S")))
        mock_context['engine']['msec'] = 60 * 60 * 1000
        time_actual = IkaUtils.getTime(mock_context)
        self.assertEqual("20150528_110000",
                         time.strftime("%Y%m%d_%H%M%S",
                                       time.localtime(time_actual)))
開發者ID:clovervidia,項目名稱:IkaLog,代碼行數:25,代碼來源:test_ikautils.py


注:本文中的ikalog.utils.IkaUtils.getTime方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。