# coding:utf8
'''
日期常用类
@author: www.crazyant.net
'''
def get_date_year_month(pm_date):
"""获取参数pm_date对应的年份和月份
"""
if not pm_date:
raise Exception("get_curr_year_month: pm_date can not be None")
# get date's yyyymmddHHMMSS pattern
str_date = str(pm_date).replace("-", "").replace(" ", "").replace(":", "")
year = str_date[:4]
month = str_date[4:6]
return year, month
# coding: utf8 """ 测试date_service.py @author: peishuaishuai """ import unittest from service import date_service class DateServiceTest(unittest.TestCase): """ test clean_tb_async_src_acct.py """ def setup(self): """在这里做资源的初始化 """ pass def tearDown(self): """在这里做资源的释放 """ pass def test_get_date_year_month_1(self): """ 测试方法1,测试方法应该以test_开头 """ pm_date = "2015-11-25 14:40:52" year, month = date_service.get_date_year_month(pm_date) self.assertEqual(year, "2015", "year not equal") self.assertEqual(month, "11", "month not equal") def test_get_date_year_month_2(self): """ 测试方法1,测试方法应该以test_开头 """ pm_date = "20161225144052" year, month = date_service.get_date_year_month(pm_date) self.assertEqual(year, "2016", "year not equal") self.assertEqual(month, "12", "month not equal") # test main if __name__ == "__main__": unittest.main()
.. ---------------------------------------------------------------------- Ran 2 tests in 0.000s OK
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有