Get Request Object in Django Test Client

I’m writing integration testing and I have to call some of my function and my function require to pass request object on it. Here is how to get request object in django test client. I’m using “APITestCase” form DRF.

response = self.client.get(path='my_end_point')
request = response.wsgi_request

Reference: http://stackoverflow.com/a/32330839/1936697

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s