Saturday, September 30, 2017

Bug to set session in Django Test?

 Hi!

I have troubles setting cookie in Django test.

class Test_views(TestCase):        def test_set_cookie(self):          session = self.client.session          session['mycookie'] = 'testcookie'          session.save()          response = self.c.get(reverse('homepage'))           ...

I print the cookies in the Views to be sure:

views.py

...   def homepage(request):          print(request.session.keys())          ...

And indeed, the cookie mycookie doesn't exist.


Is it a bug?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4284642b-490e-456d-9b9e-73f84cc39683%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment