[Answered ]-How do I write setUpClass() and tearDownClass() creating and logging in a user?(Django Rest FrameWork)

1👍

Django will set self.client per default to an instance of django.test.client.Client.
You should make your client available at a different name eg. cls.api_client = APIClient().
Note that if you are setting up data in in setUpClass() you are also responsible for removing it again in tearDownClass(), for example remove the user you created as Django will not handle this for you.

Leave a comment