Fixed #3252 -- Fixed bugs in model_forms unit tests, related to recent newforms clean_data change. Thanks for the patch, mir@noris.de

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4294 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2007-01-08 18:06:22 +00:00
parent 3b4d6b4dc1
commit 0421b2597f
1 changed files with 9 additions and 6 deletions

View File

@ -67,8 +67,8 @@ __test__ = {'API_TESTS': """
<li>The URL: <input type="text" name="url" maxlength="40" /></li> <li>The URL: <input type="text" name="url" maxlength="40" /></li>
>>> f = CategoryForm({'name': 'Entertainment', 'url': 'entertainment'}) >>> f = CategoryForm({'name': 'Entertainment', 'url': 'entertainment'})
>>> f.errors >>> f.is_valid()
{} True
>>> f.clean_data >>> f.clean_data
{'url': u'entertainment', 'name': u'Entertainment'} {'url': u'entertainment', 'name': u'Entertainment'}
>>> obj = f.create() >>> obj = f.create()
@ -78,8 +78,8 @@ __test__ = {'API_TESTS': """
[<Category: Entertainment>] [<Category: Entertainment>]
>>> f = CategoryForm({'name': "It's a test", 'url': 'test'}) >>> f = CategoryForm({'name': "It's a test", 'url': 'test'})
>>> f.errors >>> f.is_valid()
{} True
>>> f.clean_data >>> f.clean_data
{'url': u'test', 'name': u"It's a test"} {'url': u'test', 'name': u"It's a test"}
>>> obj = f.create() >>> obj = f.create()
@ -91,8 +91,8 @@ __test__ = {'API_TESTS': """
If you call create() with save=False, then it will return an object that hasn't If you call create() with save=False, then it will return an object that hasn't
yet been saved. In this case, it's up to you to save it. yet been saved. In this case, it's up to you to save it.
>>> f = CategoryForm({'name': 'Third test', 'url': 'third'}) >>> f = CategoryForm({'name': 'Third test', 'url': 'third'})
>>> f.errors >>> f.is_valid()
{} True
>>> f.clean_data >>> f.clean_data
{'url': u'third', 'name': u'Third test'} {'url': u'third', 'name': u'Third test'}
>>> obj = f.create(save=False) >>> obj = f.create(save=False)
@ -109,6 +109,9 @@ If you call create() with invalid data, you'll get a ValueError.
>>> f.errors >>> f.errors
{'name': [u'This field is required.']} {'name': [u'This field is required.']}
>>> f.clean_data >>> f.clean_data
Traceback (most recent call last):
...
AttributeError: 'CategoryForm' object has no attribute 'clean_data'
>>> f.create() >>> f.create()
Traceback (most recent call last): Traceback (most recent call last):
... ...