Re: KeyError in UnitTests

2011-07-07 Thread Daniel França
Problem solved: nose.tools.set_trace :) 2011/7/8 Daniel França > but my set_trace still freezes =/ If anyone have any idea what could be > that. > > I'm on a Mac OS 10.6 > > > 2011/7/8 Daniel França > >> yeah, thanks a lot, it's not 'BR' but I passed the ID of country and state >> and it worked

Re: KeyError in UnitTests

2011-07-07 Thread Daniel França
but my set_trace still freezes =/ If anyone have any idea what could be that. I'm on a Mac OS 10.6 2011/7/8 Daniel França > yeah, thanks a lot, it's not 'BR' but I passed the ID of country and state > and it worked. =) > > > On Fri, Jul 8, 2011 at 12:15 AM, Shawn Milochik wrote: > >> Could it b

Re: KeyError in UnitTests

2011-07-07 Thread Daniel França
yeah, thanks a lot, it's not 'BR' but I passed the ID of country and state and it worked. =) On Fri, Jul 8, 2011 at 12:15 AM, Shawn Milochik wrote: > Could it be because the test is passing 'Brasil' instead of 'BR'? I'm > assuming 'BR' is a valid choice and 'Brasil' is invalid. That's why you're

Re: KeyError in UnitTests

2011-07-07 Thread Shawn Milochik
Could it be because the test is passing 'Brasil' instead of 'BR'? I'm assuming 'BR' is a valid choice and 'Brasil' is invalid. That's why you're passing 'PR' instead of 'Paraná' in your data dictionary. If the field isn't a required field, then your form.is_valid() would be true, but there wou

Re: KeyError in UnitTests

2011-07-07 Thread Daniel França
Here's the verbosity result of tests running (using nose), the most important part, I guess Creating table cadastroav_country == ERROR: Tests Novo Usuario Cliente --

Re: KeyError in UnitTests

2011-07-07 Thread Daniel França
I was thinking, if country isn't created, so this test should fail, but that's not what happen when I was using nose *country = Country.objects.get(pk=35)* *self.assertEqual( country.name, 'Brasil' )* * * On Thu, Jul 7, 2011 at 11:47 PM, Shawn Milochik wrote: > On 07/07/2011 10:

Re: KeyError in UnitTests

2011-07-07 Thread Shawn Milochik
On 07/07/2011 10:44 PM, Daniel França wrote: I changed the test runner to default and the error message is a lot more clear. I got a DatabaseError: no such table: cadastroav_country but this should be created by tests, right? I'm using South, maybe it's a problem? The problem could be with y

Re: KeyError in UnitTests

2011-07-07 Thread Daniel França
I changed the test runner to default and the error message is a lot more clear. I got a DatabaseError: no such table: cadastroav_country but this should be created by tests, right? I'm using South, maybe it's a problem? 2011/7/7 Daniel França > I did some tests > I put self.cleaned_data['X'] >

Re: KeyError in UnitTests

2011-07-07 Thread Daniel França
I did some tests I put self.cleaned_data['X'] where X I change to all the fields of my form, it in *def clean() *function and it seems only 2 fields aren't available, state and country, I believe that it's not a coincidence that both of them are foreign key(objects). I'm using a sqlite database an

Re: KeyError in UnitTests

2011-07-07 Thread Shawn Milochik
You should be able to use pdb and then examine variables in scope. Aren't you getting a pdb prompt? Are you redirecting your output? You can also using logging and put a bunch of debug statements in to narrow down where the problem lies. If you can make a bare-bones copy of your app that dupl

Re: KeyError in UnitTests

2011-07-07 Thread Daniel França
I already tried to put the code in def clean(), same error, and I did this change you suggested andré, but same error again. as I said using the manual process the validation works fine I don't know how to debug this in unit tests, pdb.set_trace simply freeze my running tests =/ On Thu, Jul 7, 2

Re: KeyError in UnitTests

2011-07-07 Thread Andre Terra
My guess is that the input for the country field in the test is not the same as when a user POSTs the form. This is probably because you're passing a Country instance rather than country.name in your 'values' variable. Furthermore, if country can be blank, you should use if cleaned_data.get('cou

Re: KeyError in UnitTests

2011-07-07 Thread Shawn Milochik
If you want to mess with 'country' then you write a clean_country(self) function. If you want to mess with 'document' you write a clean_document(self) function. If you want to do something with one and be sure the other is also available, you write a clean(self) function, which executes after

KeyError in UnitTests

2011-07-07 Thread Daniel França
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