Django Forms Testing

From WikiOD

One core feature of Django is unit tests.

This topic intends to bring a complete documentation on how to test forms.

Simple Test[edit | edit source]

from django.test import TestCase
from myapp.forms import MyForm

class MyAppTests(TestCase):
    def test_forms(self):
        form_data = {'field1': 'fieldvalue1'}
        form = MyForm(data=form_data)
        self.assertTrue(form.is_valid())

Credit:Stack_Overflow_Documentation

About This Page

This page was last modified on 25 May 2021, at 18:24.