2012-05-09 26 views
0

所以我唯一能找到的是如何在測試期間設置會話。我想要的是檢查視圖是否將會話設置爲特定值。測試會話是否設置爲特定值

這是我想象這應該是這樣的:可

c = Client() 
response = c.post('/whatever/') 
self.assertEqual('wanted value', response.session['my_value']) 

所以cookie,但不session。這不可能很難。

回答

0

客戶端具有session屬性,如in the documentation所示。

+0

只有問題是它不起作用。我想這是關係到這個問題:http://stackoverflow.com/questions/2550078/how-do-i-properly-unit-test-a-django-session來自Rails,這是非常傷心的。 – Grocery

相關問題