Hi!
I'm testing a Django application where I'm using i18n.
The problem is with a test that says that a word with an accent
(spanish) is the same as a word without an accent. And although I have
established my own error messages it shows other error message when
using a word with accents.
The problem is with the second test shown.
I have these sentences in settings.py:
TEST_DATABASE_CHARSET='utf8'
TEST_DATABASE_COLLATION='utf8_spanish_ci'
------ code ------
class Responsable(models.Model):
user = models.ForeignKey(User, unique=True)
nombre = models.CharField('Nombre', max_length=200, unique=True)
email = models.EmailField('Email', max_length=100, unique=True)
responsable_lopd = models.BooleanField('Responsable LOPD')
def __unicode__(self):
return self.nombre
class ResponsableForm(forms.ModelForm):
def clean_nombre(self):
nombre = self.cleaned_data['nombre']
if nombre in [u.nombre for u in Responsable.objects.all()]:
raise forms.ValidationError('Ya existe un responsable con
este nombre')
return nombre
class Meta:
model = Responsable
def test_agregar_responsable_nombre_duplicado(self):
respuesta = self.client.post('/responsables/agregar/',
{
'username':'pepe',
'password':'qwerty',
'confirma_password':'qwerty',
'nombre':'Pepe Lopez',
'email':'[EMAIL PROTECTED]',
'responsable_lopd':False
})
respuesta2 = self.client.post('/responsables/agregar/',
{
'username':'josele',
'password':'qwerty',
'confirma_password':'qwerty',
'nombre':'Pepe Lopez',
'email':'[EMAIL PROTECTED]',
'responsable_lopd':False
})
self.assertFormError(respuesta2, 'responsable_form', 'nombre', 'Ya
existe un responsable con este nombre')
def test_agregar_responsable_nombre_duplicado_tildes(self):
respuesta = self.client.post('/responsables/agregar/',
{
'username':'josele',
'password':'qwerty',
'confirma_password':'qwerty',
'nombre':'José López',
'email':'[EMAIL PROTECTED]',
'responsable_lopd':False
})
respuesta2 = self.client.post('/responsables/agregar/',
{
'username':'joselito',
'password':'qwerty',
'confirma_password':'qwerty',
'nombre':'Jose Lopez',
'email':'[EMAIL PROTECTED]',
'responsable_lopd':False
})
self.assertFormError(respuesta2, 'responsable_form', 'nombre', 'Ya
existe un responsable con este nombre')
FAIL: test_agregar_responsable_nombre_duplicado_tildes
(gesfich.fichlopd.tests.RegistrarUsuariosTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/fcano/GesFichLOPD/gesfich/../gesfich/fichlopd/tests.py",
line 228, in test_agregar_responsable_nombre_duplicado_tildes
self.assertFormError(respuesta2, 'responsable_form', 'nombre', 'Ya
existe un responsable con este nombre')
File "/usr/lib/python2.5/site-packages/django/test/testcases.py",
line 317, in assertFormError
repr(field_errors)))
AssertionError: The field 'nombre' on form 'responsable_form' in
context 0 does not contain the error 'Ya existe un responsable con
este nombre' (actual errors: [u'Responsable with this Nombre already
exists.'])
----------------------------------------------------------------------
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---