from __future__ import unicode_literals from django.contrib.localflavor.jp.forms import (JPPostalCodeField, JPPrefectureSelect) from django.test import SimpleTestCase class JPLocalFlavorTests(SimpleTestCase): def test_JPPrefectureSelect(self): f = JPPrefectureSelect() out = '''''' self.assertHTMLEqual(f.render('prefecture', 'kanagawa'), out) def test_JPPostalCodeField(self): error_format = ['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)