There's a test in Django's test suite for this: 
https://github.com/django/django/blob/fd866c25d1665b73aff0d8312c414ae6f69812a3/tests/test_client_regress/tests.py#L1009-L1015

I guess you'll need to figure out how your project differs from that.

On Saturday, September 30, 2017 at 6:30:25 AM UTC-4, ThePhi wrote:
>
>  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+unsubscr...@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/14c2d75d-9438-4ca0-819e-b5f009ca6ce3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to