diff --git a/tests/regressiontests/forms/localflavor/is_.py b/tests/regressiontests/forms/localflavor/is_.py
index e71c2dd8de..fa6b133f16 100644
--- a/tests/regressiontests/forms/localflavor/is_.py
+++ b/tests/regressiontests/forms/localflavor/is_.py
@@ -1,103 +1,199 @@
-# -*- coding: utf-8 -*-
-# Tests for the contrib/localflavor/ IS form fields.
+from django.contrib.localflavor.is_.forms import (ISIdNumberField,
+ ISPhoneNumberField, ISPostalCodeSelect)
-tests = r"""
-## ISIdNumberField #############################################################
+from utils import LocalFlavorTestCase
->>> from django.contrib.localflavor.is_.forms import *
->>> f = ISIdNumberField()
->>> f.clean('2308803449')
-u'230880-3449'
->>> f.clean('230880-3449')
-u'230880-3449'
->>> f.clean('230880 3449')
-u'230880-3449'
->>> f.clean('230880343')
-Traceback (most recent call last):
-...
-ValidationError: [u'Ensure this value has at least 10 characters (it has 9).', u'Enter a valid Icelandic identification number. The format is XXXXXX-XXXX.']
->>> f.clean('230880343234')
-Traceback (most recent call last):
-...
-ValidationError: [u'Ensure this value has at most 11 characters (it has 12).', u'Enter a valid Icelandic identification number. The format is XXXXXX-XXXX.']
->>> f.clean('abcdefghijk')
-Traceback (most recent call last):
-...
-ValidationError: [u'Enter a valid Icelandic identification number. The format is XXXXXX-XXXX.']
->>> f.clean('')
-Traceback (most recent call last):
-...
-ValidationError: [u'This field is required.']
->>> f.clean(None)
-Traceback (most recent call last):
-...
-ValidationError: [u'This field is required.']
->>> f.clean('2308803439')
-Traceback (most recent call last):
-...
-ValidationError: [u'The Icelandic identification number is not valid.']
->>> f.clean('2308803440')
-u'230880-3440'
->>> f = ISIdNumberField(required=False)
->>> f.clean(None)
-u''
->>> f.clean('')
-u''
-## ISPhoneNumberField #############################################################
-
->>> from django.contrib.localflavor.is_.forms import *
->>> f = ISPhoneNumberField()
->>> f.clean('1234567')
-u'1234567'
->>> f.clean('123 4567')
-u'1234567'
->>> f.clean('123-4567')
-u'1234567'
->>> f.clean('123-456')
-Traceback (most recent call last):
-...
-ValidationError: [u'Enter a valid value.']
->>> f.clean('123456')
-Traceback (most recent call last):
-...
-ValidationError: [u'Ensure this value has at least 7 characters (it has 6).', u'Enter a valid value.']
->>> f.clean('123456555')
-Traceback (most recent call last):
-...
-ValidationError: [u'Ensure this value has at most 8 characters (it has 9).', u'Enter a valid value.']
->>> f.clean('abcdefg')
-Traceback (most recent call last):
-ValidationError: [u'Enter a valid value.']
->>> f.clean(' 1234567 ')
-Traceback (most recent call last):
-...
-ValidationError: [u'Ensure this value has at most 8 characters (it has 9).', u'Enter a valid value.']
->>> f.clean(' 12367 ')
-Traceback (most recent call last):
-...
-ValidationError: [u'Enter a valid value.']
-
->>> f.clean('')
-Traceback (most recent call last):
-...
-ValidationError: [u'This field is required.']
->>> f.clean(None)
-Traceback (most recent call last):
-...
-ValidationError: [u'This field is required.']
->>> f = ISPhoneNumberField(required=False)
->>> f.clean(None)
-u''
->>> f.clean('')
-u''
-
-## ISPostalCodeSelect #############################################################
-
->>> from django.contrib.localflavor.is_.forms import *
->>> f = ISPostalCodeSelect()
-
->>> f.render('foo', 'bar')
-u''
-"""
+class ISLocalFlavorTests(LocalFlavorTestCase):
+ def test_ISPostalCodeSelect(self):
+ f = ISPostalCodeSelect()
+ out = u''''''
+ self.assertEqual(f.render('foo', 'bar'), out)
+
+ def test_ISIdNumberField(self):
+ error_atleast = [u'Ensure this value has at least 10 characters (it has 9).']
+ error_invalid = [u'Enter a valid Icelandic identification number. The format is XXXXXX-XXXX.']
+ error_atmost = [u'Ensure this value has at most 11 characters (it has 12).']
+ error_notvalid = [u'The Icelandic identification number is not valid.']
+ valid = {
+ '2308803449': '230880-3449',
+ '230880-3449': '230880-3449',
+ '230880 3449': '230880-3449',
+ '2308803440': '230880-3440',
+ }
+ invalid = {
+ '230880343': error_atleast + error_invalid,
+ '230880343234': error_atmost + error_invalid,
+ 'abcdefghijk': error_invalid,
+ '2308803439': error_notvalid,
+
+ }
+ self.assertFieldOutput(ISIdNumberField, valid, invalid)
+
+ def test_ISPhoneNumberField(self):
+ error_invalid = [u'Enter a valid value.']
+ error_atleast = [u'Ensure this value has at least 7 characters (it has 6).']
+ error_atmost = [u'Ensure this value has at most 8 characters (it has 9).']
+ valid = {
+ '1234567': '1234567',
+ '123 4567': '1234567',
+ '123-4567': '1234567',
+ }
+ invalid = {
+ '123-456': error_invalid,
+ '123456': error_atleast + error_invalid,
+ '123456555': error_atmost + error_invalid,
+ 'abcdefg': error_invalid,
+ ' 1234567 ': error_atmost + error_invalid,
+ ' 12367 ': error_invalid
+ }
+ self.assertFieldOutput(ISPhoneNumberField, valid, invalid)
diff --git a/tests/regressiontests/forms/localflavortests.py b/tests/regressiontests/forms/localflavortests.py
index 47dfd6d95c..2f5216f4d9 100644
--- a/tests/regressiontests/forms/localflavortests.py
+++ b/tests/regressiontests/forms/localflavortests.py
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
from localflavor.cz import tests as localflavor_cz_tests
-from localflavor.is_ import tests as localflavor_is_tests
from localflavor.it import tests as localflavor_it_tests
from localflavor.jp import tests as localflavor_jp_tests
from localflavor.kw import tests as localflavor_kw_tests
@@ -31,12 +30,12 @@ from localflavor.generic import GenericLocalFlavorTests
from localflavor.id import IDLocalFlavorTests
from localflavor.ie import IELocalFlavorTests
from localflavor.il import ILLocalFlavorTests
+from localflavor.is_ import ISLocalFlavorTests
from localflavor.tr import TRLocalFlavorTests
__test__ = {
'localflavor_cz_tests': localflavor_cz_tests,
- 'localflavor_is_tests': localflavor_is_tests,
'localflavor_it_tests': localflavor_it_tests,
'localflavor_jp_tests': localflavor_jp_tests,
'localflavor_kw_tests': localflavor_kw_tests,
diff --git a/tests/regressiontests/forms/tests/__init__.py b/tests/regressiontests/forms/tests/__init__.py
index 065a8beb47..7c862ad294 100644
--- a/tests/regressiontests/forms/tests/__init__.py
+++ b/tests/regressiontests/forms/tests/__init__.py
@@ -29,5 +29,6 @@ from regressiontests.forms.localflavortests import (
IDLocalFlavorTests,
IELocalFlavorTests,
ILLocalFlavorTests,
+ ISLocalFlavorTests,
TRLocalFlavorTests,
)