mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Fixed #5546: split form unit tests into manageable chunks. This isn't a perfect fix since the chunks aren't yet autodiscovered, but that shouldn't prevent checking this in. Thanks, Leo Soto.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6379 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
48
tests/regressiontests/forms/localflavor/uk.py
Normal file
48
tests/regressiontests/forms/localflavor/uk.py
Normal file
@@ -0,0 +1,48 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Tests for the contrib/localflavor/ UK form fields.
|
||||
|
||||
tests = r"""
|
||||
# UKPostcodeField #############################################################
|
||||
|
||||
UKPostcodeField validates that the data is a valid UK postcode.
|
||||
>>> from django.contrib.localflavor.uk.forms import UKPostcodeField
|
||||
>>> f = UKPostcodeField()
|
||||
>>> f.clean('BT32 4PX')
|
||||
u'BT32 4PX'
|
||||
>>> f.clean('GIR 0AA')
|
||||
u'GIR 0AA'
|
||||
>>> f.clean('BT324PX')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
ValidationError: [u'Enter a postcode. A space is required between the two postcode parts.']
|
||||
>>> 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(None)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
ValidationError: [u'This field is required.']
|
||||
>>> f.clean('')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
ValidationError: [u'This field is required.']
|
||||
|
||||
>>> f = UKPostcodeField(required=False)
|
||||
>>> f.clean('BT32 4PX')
|
||||
u'BT32 4PX'
|
||||
>>> f.clean('GIR 0AA')
|
||||
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.']
|
||||
>>> f.clean('BT324PX')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
ValidationError: [u'Enter a postcode. A space is required between the two postcode parts.']
|
||||
>>> f.clean(None)
|
||||
u''
|
||||
>>> f.clean('')
|
||||
u''
|
||||
"""
|
||||
Reference in New Issue
Block a user