示例#1
0
    def test_invalid(self):
        try:
            code = capostcode.validate("")
            self.fail('Invalid blank postal code not caught')
        except:
            pass

        try:
            code = capostcode.validate("no")
            self.fail('Invalid postal code "no" not caught')
        except:
            pass

        try:
            code = capostcode.validate("M5V M5V")
            self.fail('Invalid postal code "M5V M5V" not caught')
        except:
            pass

        try:
            code = capostcode.validate("D5V 2T6")
            self.fail('Invalid postal code "D5V 2T6" not caught -- "D" is not '
                      'a valid major geographic area or province.')
        except:
            pass
示例#2
0
 def test_invalid(self):
     try:
         code = capostcode.validate("")
         self.fail('Invalid blank postal code not caught')
     except:
         pass
     
     try:
         code = capostcode.validate("no")
         self.fail('Invalid postal code "no" not caught')
     except:
         pass
     
     try:
         code = capostcode.validate("M5V M5V")
         self.fail('Invalid postal code "M5V M5V" not caught')
     except:
         pass
     
     try:
         code = capostcode.validate("D5V 2T6")
         self.fail('Invalid postal code "D5V 2T6" not caught -- "D" is not '
                   'a valid major geographic area or province.')
     except:
         pass
示例#3
0
    def test_invalid(self):
        try:
            code = capostcode.validate("")
            self.fail('Invalid blank postal code not caught')
        except:
            pass

        try:
            code = capostcode.validate("no")
            self.fail('Invalid postal code "no" not caught')
        except:
            pass
示例#4
0
文件: tests.py 项目: hnejadi/xerobis
 def test_invalid(self):
     try:
         code = capostcode.validate("")
         self.fail('Invalid blank postal code not caught')
     except:
         pass
     
     try:
         code = capostcode.validate("no")
         self.fail('Invalid postal code "no" not caught')
     except:
         pass
示例#5
0
def ca_postcode_validator(sender, postcode=None, country=None, **kwargs):
    if country.iso2_code == 'CA':
        from l10n.validators import capostcode
        try:
            pc = capostcode.validate(postcode)
            return pc
        except ValueError:
            raise forms.ValidationError('Please enter a valid Canadian postal code.')
示例#6
0
文件: listeners.py 项目: 34/T
def ca_postcode_validator(sender, postcode=None, country=None, **kwargs):
    if country.iso2_code == 'CA':
        from l10n.validators import capostcode
        try:
            pc = capostcode.validate(postcode)
            return pc
        except ValueError, ve:
            raise forms.ValidationError('Please enter a valid Canadian postal code.')
示例#7
0
 def test_valid(self):
     code = capostcode.validate("M5V2T6")
     self.assertEqual('M5V2T6', code)
     code = capostcode.validate("m5v2t6")
     self.assertEqual('M5V2T6', code)
示例#8
0
文件: tests.py 项目: hnejadi/xerobis
 def test_valid(self):
     code = capostcode.validate("M5V2T6")
     self.assertEqual('M5V2T6', code)
     code = capostcode.validate("m5v2t6")
     self.assertEqual('M5V2T6', code)