Django testing stored session data in tests

后端 未结 1 810
攒了一身酷
攒了一身酷 2021-02-07 04:32

I have a view as such:

def ProjectInfo(request):
    if request.method == \'POST\':
        form = ProjectInfoForm(request.POST)
        if form.is_valid():
             


        
1条回答
  •  走了就别回头了
    2021-02-07 05:30

    According to the docs:

    from django.test import TestCase
    
    class SimpleTest(TestCase):
        def test_details(self):
            # Issue a GET request.
            self.client.get('/customer/details/')
            session = self.client.session
            self.assertEqual(session["somekey"], "test")
    

    0 讨论(0)
提交回复
热议问题