Ticket #3252: clean_data_tests.diff
File clean_data_tests.diff, 1.3 KB (added by , 18 years ago) |
---|
-
tests/modeltests/model_forms/models.py
a b __test__ = {'API_TESTS': """ 67 67 <li>The URL: <input type="text" name="url" maxlength="40" /></li> 68 68 69 69 >>> f = CategoryForm({'name': 'Entertainment', 'url': 'entertainment'}) 70 >>> f. errors71 {} 70 >>> f.is_valid() 71 True 72 72 >>> f.clean_data 73 73 {'url': u'entertainment', 'name': u'Entertainment'} 74 74 >>> obj = f.create() … … __test__ = {'API_TESTS': """ 78 78 [<Category: Entertainment>] 79 79 80 80 >>> f = CategoryForm({'name': "It's a test", 'url': 'test'}) 81 >>> f. errors82 {} 81 >>> f.is_valid() 82 True 83 83 >>> f.clean_data 84 84 {'url': u'test', 'name': u"It's a test"} 85 85 >>> obj = f.create() … … __test__ = {'API_TESTS': """ 91 91 If you call create() with save=False, then it will return an object that hasn't 92 92 yet been saved. In this case, it's up to you to save it. 93 93 >>> f = CategoryForm({'name': 'Third test', 'url': 'third'}) 94 >>> f. errors95 {} 94 >>> f.is_valid() 95 True 96 96 >>> f.clean_data 97 97 {'url': u'third', 'name': u'Third test'} 98 98 >>> obj = f.create(save=False) … … If you call create() with invalid data, 109 109 >>> f.errors 110 110 {'name': [u'This field is required.']} 111 111 >>> f.clean_data 112 Traceback (most recent call last): 113 ... 114 AttributeError: 'CategoryForm' object has no attribute 'clean_data' 112 115 >>> f.create() 113 116 Traceback (most recent call last): 114 117 ...