Ticket #10204: patch_and_tests_final.diff

File patch_and_tests_final.diff, 2.2 KB (added by Pablo Suárez Hdez., 15 years ago)

patch and regressiontests in same file.

  • django/contrib/localflavor/es/forms.py

     
    7575        self.nif_control = 'TRWAGMYFPDXBNJZSQVHLCKE'
    7676        self.cif_control = 'JABCDEFGHI'
    7777        self.cif_types = 'ABCDEFGHKLMNPQS'
    78         self.nie_types = 'XT'
     78        self.nie_types = 'XTYZ'
    7979        id_card_re = re.compile(r'^([%s]?)[ -]?(\d+)[ -]?([%s]?)$' % (self.cif_types + self.nie_types, self.nif_control + self.cif_control), re.IGNORECASE)
    8080        super(ESIdentityCardNumberField, self).__init__(id_card_re, max_length=None, min_length=None,
    8181                error_message=self.default_error_messages['invalid%s' % (self.only_nif and '_only_nif' or '')],
  • tests/regressiontests/forms/localflavor/es.py

     
    155155'X0012953G'
    156156>>> f.clean('x-3287690-r')
    157157'X3287690R'
     158>>> f.clean('Y-3287690-R')
     159'Y3287690R'
     160>>> f.clean('y-3287690-r')
     161'Y3287690R'
     162>>> f.clean('Y 3287690 R')
     163'Y3287690R'
     164>>> f.clean('Y-3287690-T')
     165Traceback (most recent call last):
     166...
     167ValidationError: [u'Invalid checksum for NIE.']
     168>>> f.clean('Y-03287690')
     169Traceback (most recent call last):
     170...
     171ValidationError: [u'Please enter a valid NIF, NIE, or CIF.']
     172>>> f.clean('Z-3287690-R')
     173'Z3287690R'
     174>>> f.clean('Z-3287690-T')
     175Traceback (most recent call last):
     176...
     177ValidationError: [u'Invalid checksum for NIE.']
     178>>> f.clean('Z-03287690')
     179Traceback (most recent call last):
     180...
     181ValidationError: [u'Please enter a valid NIF, NIE, or CIF.']
    158182>>> f.clean('t-03287690r')
    159183'T03287690R'
    160184>>> f.clean('P2907500I')
  • AUTHORS

     
    444444    Mykola Zamkovoi <nickzam@gmail.com>
    445445    Jarek Zgoda <jarek.zgoda@gmail.com>
    446446    Cheng Zhang
     447    Pablo Suárez Hernández <meaksh@gmail.com>
    447448
    448449A big THANK YOU goes to:
    449450
Back to Top