from django.contrib.localflavor.jp.forms import (JPPostalCodeField, JPPrefectureSelect) from utils import LocalFlavorTestCase class JPLocalFlavorTests(LocalFlavorTestCase): def test_JPPrefectureSelect(self): f = JPPrefectureSelect() out = u'''''' self.assertEqual(f.render('prefecture', 'kanagawa'), out) def test_JPPostalCodeField(self): error_format = [u'Enter a postal code in the format XXXXXXX or XXX-XXXX.'] valid = { '251-0032': '2510032', '2510032': '2510032', } invalid = { '2510-032': error_format, '251a0032': error_format, 'a51-0032': error_format, '25100321': error_format, } self.assertFieldOutput(JPPostalCodeField, valid, invalid)