Ticket #3252: clean_data_tests.diff

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

The patch.

  • tests/modeltests/model_forms/models.py

    a b __test__ = {'API_TESTS': """  
    6767<li>The URL: <input type="text" name="url" maxlength="40" /></li>
    6868
    6969>>> f = CategoryForm({'name': 'Entertainment', 'url': 'entertainment'})
    70 >>> f.errors
    71 {}
     70>>> f.is_valid()
     71True
    7272>>> f.clean_data
    7373{'url': u'entertainment', 'name': u'Entertainment'}
    7474>>> obj = f.create()
    __test__ = {'API_TESTS': """  
    7878[<Category: Entertainment>]
    7979
    8080>>> f = CategoryForm({'name': "It's a test", 'url': 'test'})
    81 >>> f.errors
    82 {}
     81>>> f.is_valid()
     82True
    8383>>> f.clean_data
    8484{'url': u'test', 'name': u"It's a test"}
    8585>>> obj = f.create()
    __test__ = {'API_TESTS': """  
    9191If you call create() with save=False, then it will return an object that hasn't
    9292yet been saved. In this case, it's up to you to save it.
    9393>>> f = CategoryForm({'name': 'Third test', 'url': 'third'})
    94 >>> f.errors
    95 {}
     94>>> f.is_valid()
     95True
    9696>>> f.clean_data
    9797{'url': u'third', 'name': u'Third test'}
    9898>>> obj = f.create(save=False)
    If you call create() with invalid data,  
    109109>>> f.errors
    110110{'name': [u'This field is required.']}
    111111>>> f.clean_data
     112Traceback (most recent call last):
     113   ...
     114AttributeError: 'CategoryForm' object has no attribute 'clean_data'
    112115>>> f.create()
    113116Traceback (most recent call last):
    114117...
Back to Top