Ticket #11958: contactform_errors.py
File contactform_errors.py, 518 bytes (added by , 15 years ago) |
---|
Line | |
---|---|
1 | from django import forms |
2 | class ContactForm(forms.Form): |
3 | subject = forms.CharField(max_length=100) |
4 | message = forms.CharField() |
5 | sender = forms.EmailField() |
6 | |
7 | |
8 | def test_contactform(): |
9 | data = { |
10 | 'subject':'my subject', |
11 | 'message':'my message', |
12 | 'sender':'invalid e-mail address', |
13 | } |
14 | |
15 | f = ContactForm(data=data) |
16 | |
17 | if not f.is_valid(): |
18 | print f.errors # prints "<ul class="errorlist"><li>sender<ul class="errorlist"><li>Enter a valid e-mail address.</li></ul></li></ul>" |