1
0
mirror of https://github.com/django/django.git synced 2024-12-29 04:26:28 +00:00
django/tests/regressiontests/localflavor/gb/tests.py
Claude Paroz 4a103086d5 Fixed #18269 -- Applied unicode_literals for Python 3 compatibility.
Thanks Vinay Sajip for the support of his django3 branch and
Jannis Leidel for the review.
2012-06-07 18:08:47 +02:00

33 lines
1.0 KiB
Python

from __future__ import unicode_literals
from django.contrib.localflavor.gb.forms import GBPostcodeField
from django.test import SimpleTestCase
class GBLocalFlavorTests(SimpleTestCase):
def test_GBPostcodeField(self):
error_invalid = ['Enter a valid postcode.']
valid = {
'BT32 4PX': 'BT32 4PX',
'GIR 0AA': 'GIR 0AA',
'BT324PX': 'BT32 4PX',
' so11aa ': 'SO1 1AA',
' so1 1aa ': 'SO1 1AA',
'G2 3wt': 'G2 3WT',
'EC1A 1BB': 'EC1A 1BB',
'Ec1a1BB': 'EC1A 1BB',
}
invalid = {
'1NV 4L1D': error_invalid,
'1NV4L1D': error_invalid,
' b0gUS': error_invalid,
}
self.assertFieldOutput(GBPostcodeField, valid, invalid)
valid = {}
invalid = {
'1NV 4L1D': ['Enter a bloody postcode!'],
}
kwargs = {'error_messages': {'invalid': 'Enter a bloody postcode!'}}
self.assertFieldOutput(GBPostcodeField, valid, invalid, field_kwargs=kwargs)