Django unit test response context is None

后端 未结 2 1399
小蘑菇
小蘑菇 2021-01-23 10:44

Why is response.context None in the following tests? I\'ve checked response.content and it is \'\'. if I remove the assertIsNotNone line I get a TypeError: \'NoneType\' object

2条回答
  •  北海茫月
    2021-01-23 11:23

    I was having this issue and to fix it did the following in the setUp function:

    from django.test.utils import setup_test_environment
    setup_test_environment()
    

提交回复
热议问题