#14608: Adding a INPhoneNumberField to indian localflavor ---------------------------------------+----------------------------------- Reporter: lawgon | Owner: lawgon Type: New feature | Status: reopened Milestone: | Component: contrib.localflavor Version: SVN | Severity: Normal Resolution: | Keywords: india phone Triage Stage: Accepted | Has patch: 1 Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 1 | ---------------------------------------+-----------------------------------
Comment (by julien): Wow, it took me a long time to track this down. In fact, there's nothing really wrong with your patch. I think the problem is in the way that `django.tests.regressiontests.forms.localflavor.utils.assertFieldOutput` works. `assertFieldOutput` calls `assertRaisesRegexp` and passes the expected errors as a unicode string: In source:django/trunk/tests/regressiontests/forms/localflavor/utils.py#L40 : {{{#!python self.assertRaisesRegexp(ValidationError, unicode(errors), required.clean, input ) }}} ... and further down the track, in `assertRaisesRegexp`, that string is compiled as a regular expression: In source:django/trunk/django/utils/unittest/case.py#L991 : {{{#!python expected_regexp = re.compile(expected_regexp) }}} Now, the issue here is that the error message in your patch contains some '-' characters, which are interpreted as a range, hence the 'bad character range' error that is raised when running the tests: {{{#!python class INLocalFlavorTests(LocalFlavorTestCase): def test_INPhoneNumberField(self): error_format = [u'Phone numbers must be in 02X-7X or 03X-6X or 04X-5X format.'] ... }}} Remove those '-' characters and the tests will pass... Now of course, this is not satisfactory. I tend to think it's a bug in the test framework. Let me know if somebody has an opinion on this, otherwise I might bring this up on django-dev. -- Ticket URL: <http://code.djangoproject.com/ticket/14608#comment:27> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.