1 from django
.contrib
.localflavor
.gb
.forms
import GBPostcodeField
3 from django
.test
import SimpleTestCase
6 class GBLocalFlavorTests(SimpleTestCase
):
7 def test_GBPostcodeField(self
):
8 error_invalid
= [u
'Enter a valid postcode.']
10 'BT32 4PX': 'BT32 4PX',
12 'BT324PX': 'BT32 4PX',
13 ' so11aa ': 'SO1 1AA',
14 ' so1 1aa ': 'SO1 1AA',
16 'EC1A 1BB': 'EC1A 1BB',
17 'Ec1a1BB': 'EC1A 1BB',
20 '1NV 4L1D': error_invalid
,
21 '1NV4L1D': error_invalid
,
22 ' b0gUS': error_invalid
,
24 self
.assertFieldOutput(GBPostcodeField
, valid
, invalid
)
27 '1NV 4L1D': [u
'Enter a bloody postcode!'],
29 kwargs
= {'error_messages': {'invalid': 'Enter a bloody postcode!'}}
30 self
.assertFieldOutput(GBPostcodeField
, valid
, invalid
, field_kwargs
=kwargs
)