Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is difference between `django.test.APITestCase` and `rest_framework.test.TestCase` in `python-django`

What is the major difference in these test classes django.test.TestCase and rest_framework.test.APITestCase . which is Better to test my views.py ? can you suggest me documentations to understand about these.

Thank you in advance. :-)

like image 285
Vamsi Krishna Kolli Avatar asked Jan 18 '26 13:01

Vamsi Krishna Kolli


2 Answers

Difference between rest_framework.test.APITestCase and django.test.testcases.TestCase in HTTP Client they use (source: github).

With rest_framework APIClient it easier to test API than with Django Client. For example, less work with json responses. See more: http://www.django-rest-framework.org/api-guide/testing/

like image 62
alexfv Avatar answered Jan 21 '26 04:01

alexfv


APITestCase in rest_framework.test is to test the api's in the rest. It is specific for the api operations and api calls. Django.test.TestCase is used to test the Django classes.

like image 23
Vamsi Krishna Kolli Avatar answered Jan 21 '26 03:01

Vamsi Krishna Kolli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!