Hi,
I'm starting to use unit tests in Django, I got stuck in a client test I
can't figure out the solution,
As I don't have much experience in Django unit tests maybe the error is easy
to solve


I got this error message executing unit tests
   apps/usuarios/forms.py", line 95, in clean_document
    country  = self.cleaned_data['country']
KeyError: 'country'

this is the line (here's cleaning country, but whatever, there's no data at
all)
def clean_document(self):
     country  = self.cleaned_data['country']

If I do the manual process of inserting values in form, it works fine, the
problem is in the unit tests, here's my class and function that the problem
happens

class UsersTestCase(TestCase):
    fixtures = ['initial_data.yaml',]

    def test_new_user_client(self):
        """
        Testing new user client
        """
        country = Country.objects.get(pk=35)
        self.assertEqual( country.name, 'Brasil' )

        state = State.objects.get(abrev_name='RJ')
        self.assertEqual( state.full_name, 'Rio de Janeiro' )

        c = Client()
        values = {
            'first_name': 'Teste',
            'last_name': 'Sobrenome',
            'address': 'Avenida de Teste',
            'number': 9876,
            'city': 'Rio de Janeiro',
            'postal_code': '12345-000',
            'state': state,
            'country': country,
            'telephone': '+55 21 2345 9841',
            'email': '[email protected]',
            'reg_type': 'PF',
            'document': '692.694.115-75',
        }

        resp = c.get( reverse('new_client'), { 'extra_context':
{'user_type':'C',}})

        self.assertEqual(resp.context['user_type'], 'C')
        self.assertEqual(resp.context['title'], 'Cliente')
        self.assertFalse(resp.context['aprov'])

        *resp = c.post(reverse('new_client'), values) #HERE'S THE ERROR*


Any idea of what's the problem?
And how can I use pdb/ipdb together with django unit tests? I tried to use
that, but the tests simply stuck and no shell appears for me.


Att,
Daniel França

-- 
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.

Reply via email to