diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-12-19 04:43:47 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-12-19 04:43:47 +0000 |
| commit | a35ca605d62d1b97eb595dcaa27b0904a0fe2182 (patch) | |
| tree | 03ab93cd5b351d46c9fa8c6b495b5afd738e22d7 /tests | |
| parent | aec96649f0c107c16721d4c56267f0acc990d58f (diff) | |
Fixed #5670 -- Changed the validation of the UK postcode widget to allow for easier input. Normalisation still returns the same things as previously. Patch from scott@staplefish.com.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6952 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/forms/localflavor/uk.py | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/tests/regressiontests/forms/localflavor/uk.py b/tests/regressiontests/forms/localflavor/uk.py index d7848f70a8..258c22e5a9 100644 --- a/tests/regressiontests/forms/localflavor/uk.py +++ b/tests/regressiontests/forms/localflavor/uk.py @@ -12,13 +12,15 @@ u'BT32 4PX' >>> f.clean('GIR 0AA') u'GIR 0AA' >>> f.clean('BT324PX') +u'BT32 4PX' +>>> f.clean('1NV 4L1D') Traceback (most recent call last): ... -ValidationError: [u'Enter a postcode. A space is required between the two postcode parts.'] ->>> f.clean('1NV 4L1D') +ValidationError: [u'Enter a valid postcode.'] +>>> f.clean('1NV4L1D') Traceback (most recent call last): ... -ValidationError: [u'Enter a postcode. A space is required between the two postcode parts.'] +ValidationError: [u'Enter a valid postcode.'] >>> f.clean(None) Traceback (most recent call last): ... @@ -27,7 +29,20 @@ ValidationError: [u'This field is required.'] Traceback (most recent call last): ... ValidationError: [u'This field is required.'] - +>>> f.clean(' so11aa ') +u'SO1 1AA' +>>> f.clean(' so1 1aa ') +u'SO1 1AA' +>>> f.clean('G2 3wt') +u'G2 3WT' +>>> f.clean('EC1A 1BB') +u'EC1A 1BB' +>>> f.clean('Ec1a1BB') +u'EC1A 1BB' +>>> f.clean(' b0gUS') +Traceback (most recent call last): +... +ValidationError: [u'Enter a valid postcode.'] >>> f = UKPostcodeField(required=False) >>> f.clean('BT32 4PX') u'BT32 4PX' @@ -36,11 +51,9 @@ u'GIR 0AA' >>> f.clean('1NV 4L1D') Traceback (most recent call last): ... -ValidationError: [u'Enter a postcode. A space is required between the two postcode parts.'] +ValidationError: [u'Enter a valid postcode.'] >>> f.clean('BT324PX') -Traceback (most recent call last): -... -ValidationError: [u'Enter a postcode. A space is required between the two postcode parts.'] +u'BT32 4PX' >>> f.clean(None) u'' >>> f.clean('') |
