Last active
January 4, 2017 16:36
-
-
Save doismellburning/3a7d78590a2148f1a85bdcf1bd5acb35 to your computer and use it in GitHub Desktop.
Django TestClient sessions - what am I missing...?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
====================================================================== | |
FAIL: test_clear_token_with_token (article.tests.test_views.ArticleViewsTest) | |
---------------------------------------------------------------------- | |
Traceback (most recent call last): | |
File "/root/article/tests/test_views.py", line 92, in test_clear_token_with_token | |
self.assertIsNotNone(self.client.session.get('token')) | |
AssertionError: unexpectedly None | |
---------------------------------------------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_clear_token_with_token(self): | |
url = reverse("article:clear_token") | |
# https://docs.djangoproject.com/en/1.10/topics/testing/tools/#django.test.Client.session | |
# "To modify the session and then save it, it must be stored in a variable first | |
# (because a new SessionStore is created every time this property is accessed):" | |
session = self.client.session | |
session['token'] = "loremipsum" | |
session.save() | |
self.assertIsNotNone(self.client.session.get('token')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment