Django

Code

Changeset 4527

Show
Ignore:
Timestamp:
02/15/07 15:26:43 (2 years ago)
Author:
adrian
Message:

Fixed #3503 -- Added newforms UKPostcodeField in django.contrib.localflavor.uk. Thanks for the patch, Jonathan Buchanan

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/tests/regressiontests/forms/tests.py

    r4525 r4527  
    33283328u'' 
    33293329 
     3330# UKPostcodeField ############################################################## 
     3331 
     3332UKPostcodeField validates that the data is a valid UK postcode. 
     3333>>> from django.contrib.localflavor.uk.forms import UKPostcodeField 
     3334>>> f = UKPostcodeField() 
     3335>>> f.clean('BT32 4PX') 
     3336u'BT32 4PX' 
     3337>>> f.clean('GIR 0AA') 
     3338u'GIR 0AA' 
     3339>>> f.clean('BT324PX') 
     3340Traceback (most recent call last): 
     3341... 
     3342ValidationError: [u'Enter a postcode. A space is required between the two postcode parts.'] 
     3343>>> f.clean('1NV 4L1D') 
     3344Traceback (most recent call last): 
     3345... 
     3346ValidationError: [u'Enter a postcode. A space is required between the two postcode parts.'] 
     3347>>> f.clean(None) 
     3348Traceback (most recent call last): 
     3349... 
     3350ValidationError: [u'This field is required.'] 
     3351>>> f.clean('') 
     3352Traceback (most recent call last): 
     3353... 
     3354ValidationError: [u'This field is required.'] 
     3355 
     3356>>> f = UKPostcodeField(required=False) 
     3357>>> f.clean('BT32 4PX') 
     3358u'BT32 4PX' 
     3359>>> f.clean('GIR 0AA') 
     3360u'GIR 0AA' 
     3361>>> f.clean('1NV 4L1D') 
     3362Traceback (most recent call last): 
     3363... 
     3364ValidationError: [u'Enter a postcode. A space is required between the two postcode parts.'] 
     3365>>> f.clean('BT324PX') 
     3366Traceback (most recent call last): 
     3367... 
     3368ValidationError: [u'Enter a postcode. A space is required between the two postcode parts.'] 
     3369>>> f.clean(None) 
     3370u'' 
     3371>>> f.clean('') 
     3372u'' 
     3373 
    33303374################################# 
    33313375# Tests of underlying functions #