如何进行测试进行现有的COIN_ID?
我的代码
有必要替代现有的COIN_ID,因此将来,由于删除了ID = 2的硬币,因此测试不会下降。
class ModelTransactionTest(TestCase):
@freeze_time(timezone.now())
def test_auto_setting_date_if_field_empty(self):
field = Transaction.objects.create(rubles_cost=1, purchase_price=1, amount=1,
dollars_cost=1, coin_id=2)
self.assertEqual(timezone.now(), field.date)
My code
It is necessary that the test itself could substitute the existing coin_id, so that in the future the test does not fall, for example, due to the removal of a coin under id=2
class ModelTransactionTest(TestCase):
@freeze_time(timezone.now())
def test_auto_setting_date_if_field_empty(self):
field = Transaction.objects.create(rubles_cost=1, purchase_price=1, amount=1,
dollars_cost=1, coin_id=2)
self.assertEqual(timezone.now(), field.date)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该在测试中创建硬币实例
You should create coin instance in tests