Python 如何为Django中的测试用例验证InlineFormSetFactory中的文档(pdf)
forms.py test_forms.py 如何为Django中的测试用例验证InlineFormSetFactory中的文档(pdf) 目前,testcase在“form-0-test_文档”中出现错误:“dir/testDoc.pdf”Python 如何为Django中的测试用例验证InlineFormSetFactory中的文档(pdf),python,django,inline-formset,Python,Django,Inline Formset,forms.py test_forms.py 如何为Django中的测试用例验证InlineFormSetFactory中的文档(pdf) 目前,testcase在“form-0-test_文档”中出现错误:“dir/testDoc.pdf” class TestDocumentInline(InlineFormSetFactory): model = TestDocument fields = ['document_test_type', 'test_notes', 'tes
class TestDocumentInline(InlineFormSetFactory):
model = TestDocument
fields = ['document_test_type', 'test_notes', 'test_document']
factory_kwargs = {'extra': 1, 'can_delete': True}
@pytest.mark.django_db
class DocumentInlineTest(TestCase):
def test_valid_testdocument(self):
test_inline = TestDocumentInline(request=self.factory,
instance=self.test,
parent_model=Test)
test_formset = test_inline.get_formset()
formset = test_formset({
'form-TOTAL_FORMS': '1',
'form-INITIAL_FORMS': '0',
'form-MAX_NUM_FORMS': '2',
'form-0-document_test_type': "Test",
'form-0-test_notes': "test_notes",
'form-0-test_document': "dir/testDoc.pdf",
}, prefix="form")
self.assertTrue(formset.is_valid())