Code

Ticket #3252: clean_data_tests.diff

File clean_data_tests.diff, 1.3 KB (added by mir@…, 8 years ago)

The patch.

Line 
1--- a/tests/modeltests/model_forms/models.py
2+++ b/tests/modeltests/model_forms/models.py
3@@ -67,8 +67,8 @@ __test__ = {'API_TESTS': """
4 <li>The URL: <input type="text" name="url" maxlength="40" /></li>
5 
6 >>> f = CategoryForm({'name': 'Entertainment', 'url': 'entertainment'})
7->>> f.errors
8-{}
9+>>> f.is_valid()
10+True
11 >>> f.clean_data
12 {'url': u'entertainment', 'name': u'Entertainment'}
13 >>> obj = f.create()
14@@ -78,8 +78,8 @@ __test__ = {'API_TESTS': """
15 [<Category: Entertainment>]
16 
17 >>> f = CategoryForm({'name': "It's a test", 'url': 'test'})
18->>> f.errors
19-{}
20+>>> f.is_valid()
21+True
22 >>> f.clean_data
23 {'url': u'test', 'name': u"It's a test"}
24 >>> obj = f.create()
25@@ -91,8 +91,8 @@ __test__ = {'API_TESTS': """
26 If you call create() with save=False, then it will return an object that hasn't
27 yet been saved. In this case, it's up to you to save it.
28 >>> f = CategoryForm({'name': 'Third test', 'url': 'third'})
29->>> f.errors
30-{}
31+>>> f.is_valid()
32+True
33 >>> f.clean_data
34 {'url': u'third', 'name': u'Third test'}
35 >>> obj = f.create(save=False)
36@@ -109,6 +109,9 @@ If you call create() with invalid data,
37 >>> f.errors
38 {'name': [u'This field is required.']}
39 >>> f.clean_data
40+Traceback (most recent call last):
41+   ...
42+AttributeError: 'CategoryForm' object has no attribute 'clean_data'
43 >>> f.create()
44 Traceback (most recent call last):
45 ...