我正在为我编写的使用datetime.utcnow()
的特定函数编写测试,这是必要的,因为它可以实时运行。测试的形状如下:
1.测试:
*Important_Date, in datetime format*
Function which uses Important_Date
*assertfunction*
2.使用Important_Date
的函数
if Condition:
return Important_Date < (datetime.utcnow() - timedelta(days=7))
现在,问题是,只要Important_Date
距离datetime.utcnow()
不到7
天,测试用例就会通过。否则,它将失败
现在,要求是Important_Date
应该设置为我从datetime.utcnow()
得到的日期之前的1/2/3天。我不知道该怎么做
我试过datetime.utcnow() - 1
,但不起作用
有办法做到这一点吗?感谢您的帮助
我使用的是PyCharm上的Python3,运行在Windows10上
目前没有回答
相关问题 更多 >
编程相关推荐