1
假设我有一个测试视图的单元测试。该观点需要一个表格来做一些处理。我的单元测试看起来像这样:如何在Django单元测试中的请求对象中传递表单对象?
class ViewTests(TestCase):
def setUp(self):
self.factory = RequestFactory()
def test_login_view_post(self):
# require form object to pass it in post function
response = self.client.post(reverse('login'))
self.assertContains(response, "Your username and password didn't match", status_code=200)
有人能告诉我如何在post函数中传递表单对象吗?
谢谢。