gpt4 book ai didi

python-3.x - `django.test.APITestCase` 和 `rest_framework.test.TestCase` 中的 `python-django` 有什么区别

转载 作者:行者123 更新时间:2023-12-05 04:10:47 25 4
gpt4 key购买 nike

这些测试类 django.test.TestCaserest_framework.test.APITestCase 的主要区别是什么。哪个更好地测试我的 views.py ?你能建议我了解这些的文档吗?

提前致谢。 :-)

最佳答案

他们使用的 HTTP 客户端中 rest_framework.test.APITestCase 和 django.test.testcases.TestCase 之间的区别(来源:github)。

使用 rest_framework APIClient 比使用 Django Client 更容易测试 API。例如,较少使用 json 响应。查看更多:http://www.django-rest-framework.org/api-guide/testing/

关于python-3.x - `django.test.APITestCase` 和 `rest_framework.test.TestCase` 中的 `python-django` 有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43973305/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com