我正在使用Django和Python 3.7。我有这种看法...
def get(request):
context = {}
if not request.GET:
tax_calculator_form = TaxCalculatorForm()
else:
...
context['form'] = tax_calculator_form
return render(request, "tax_calculator.html", context)
我想在单元测试中编写某种断言,以验证模型是否包含我的表单对象。我怎么做?到目前为止,我有
# Simple test to verify we can get the tax form
def test_get_tax_form(self):
response = self.client.get("/form")
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "tax_calculator.html")