[Fixed]-How to run tests django rest framework tests?


I believe your test methods need to start with test. Change def getList to def testGetList or def test_get_list.

As with other python tests (see https://docs.python.org/2/library/unittest.html#basic-example), if methods do not start with test they will not be run as tests.



from rest_framework.test import APITestCase

from rest_framework import status

class Portfolio_api_test(APITestCase):
def setUp(self):
Your code

def test_your_function_name(self):
    response = self.client.get('url')
    self.assertEqual(response.status_code, status.HTTP_200_OK)

Your test function name should start with test_your_function_name

Leave a comment