# -*- coding: utf-8 -*- # Tests for the contrib/localflavor/ JP form fields. tests = r""" # JPPostalCodeField ############################################################### A form field that validates its input is a Japanese postcode. Accepts 7 digits(with/out hyphen). >>> from django.contrib.localflavor.jp.forms import JPPostalCodeField >>> f = JPPostalCodeField() >>> f.clean('251-0032') u'2510032' >>> f.clean('2510032') u'2510032' >>> f.clean('2510-032') Traceback (most recent call last): ... ValidationError: [u'Enter a postal code in the format XXXXXXX or XXX-XXXX.'] >>> f.clean('251a0032') Traceback (most recent call last): ... ValidationError: [u'Enter a postal code in the format XXXXXXX or XXX-XXXX.'] >>> f.clean('a51-0032') Traceback (most recent call last): ... ValidationError: [u'Enter a postal code in the format XXXXXXX or XXX-XXXX.'] >>> f.clean('25100321') Traceback (most recent call last): ... ValidationError: [u'Enter a postal code in the format XXXXXXX or XXX-XXXX.'] >>> f.clean('') Traceback (most recent call last): ... ValidationError: [u'This field is required.'] >>> f = JPPostalCodeField(required=False) >>> f.clean('251-0032') u'2510032' >>> f.clean('2510032') u'2510032' >>> f.clean('2510-032') Traceback (most recent call last): ... ValidationError: [u'Enter a postal code in the format XXXXXXX or XXX-XXXX.'] >>> f.clean('') u'' >>> f.clean(None) u'' # JPPrefectureSelect ############################################################### A Select widget that uses a list of Japanese prefectures as its choices. >>> from django.contrib.localflavor.jp.forms import JPPrefectureSelect >>> w = JPPrefectureSelect() >>> print w.render('prefecture', 'kanagawa') """