Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.test import TestCase
- class SampleTest(TestCase):
- def setUp(self):
- # Login - seems that session cookies behave more
- # consistent this way.
- self.credentials = {'username': 'user',
- 'password': 'passwd'}
- self.client.login(**self.credentials)
- # Set additional attributes on the client object.
- ip = {'REMOTE_ADDR': '127.0.0.1'}
- setattr(self.client, 'META', ip)
- # Need to store the session in a separate variable,
- # otherwise it doesn't persist.
- session = self.client.session
- session['somekey'] = 'somevalue'
- session.save()
Add Comment
Please, Sign In to add comment