[Mailman-Developers] Postorius test debugging problem : tests_forms.py

Pranjal Yadav godricglow at gmail.com
Fri Feb 27 18:21:54 CET 2015


Abhilash,

renaming 'clean_password' to 'clean' did help in running all the tests
successfully but looking at the
coverage stats I realized the 'invalid_email' test is still not functional
since those lines are shown as 'missing'
in stats, So it was just a work around and it didn't actually help.

When I changed 'clean_email' to 'clean' both validation tests for email
worked however now
'invalid_password' test went off and gave an error.

Now I'm confused with the naming part!

On Fri, Feb 27, 2015 at 8:39 PM, Pranjal Yadav <godricglow at gmail.com> wrote:

> Hi Abhilash,
>
> Thanks for your help. I read that we need to define methods as
> clean_<fieldname> however I missed
> I was cleaning multiple fields. For the listname method it works the way
> you told me but I tried something
> similar ( http://pastebin.com/p40A19hU ) and it didn't work. If you could
> tell me why is that?
>
> Also I'm still puzzled when I run
> tox -e py27-django1.7 -- postorius.tests.test_forms.UserNewTest
> tox -e py27-django1.7 -- postorius.tests.test_forms.ListNewTest
> tox -e py27-django1.7 -- postorius.tests.test_forms.DomainNewTest
>
> output : Ran 0 tests in 0.001s
>
> But after running this
> tox -e py27-django1.7 -- postorius.tests.test_forms
>
> output : Ran 11 tests in 0.015s
>
> On Fri, Feb 27, 2015 at 5:06 PM, Abhilash Raj <raj.abhilash1 at gmail.com>
> wrote:
>
>> Hi Pranjal,
>>
>> I was able to run the tests in ListNewTest, and kind of debug the
>> other test too.
>>
>> In ListNewTest you have two tests doing the same thing, probably you
>> intended
>> at doing something else, but there is nothing in there right now.
>>
>> there is a method of django forms called as `errors`. So you can simply do
>>
>>    print form.errors
>>
>> and get the actual error in the forms printed when you run the tests.
>> When I ran
>> that I got "Passwords are not identical" error. Then I saw you changed
>> the `clean`
>> method in UserNew to `clean_password`. According to django
>> documentation[1] when
>> you are trying to access more than one field for cleaning you have to
>> use `clean`
>> method and not `clean_<fieldname>` method. Like `clean_email` method is
>> cool!
>>
>> If you print the errors for `test_form_fields_listname` method, you'd see
>> that
>> it says that 'mailman.most-desirable.org' is not a valid choice. So you
>> need to
>> first create a domain with that host in `setUp` method of `ListNewTest`.
>>
>> I hope that helps!
>>
>> [1]: https://docs.djangoproject.com/en/1.7/ref/forms/validation/
>>
>> On 20 February 2015 at 07:26, Pranjal Yadav <godricglow at gmail.com> wrote:
>> > I started writing tests to improve the coverage for postorius and I ran
>> > into few problems which I couldn't solve for past few days. I added few
>> new
>> > test cases and re-ran tox. It seems somehow none of the tests ran
>> although
>> > the tox output says "ran 11 tests in 72.332s, failures = 3"
>> >
>> > Here is the link to my tests : http://pastebin.com/1jLhVsr2
>> > I did change a few things in forms.py : http://pastebin.com/2P3vXW7W
>> >
>> > After running these tests I realized UserNewTest and ListNewTest never
>> > runs, though tox outputs it ran 11 test and failed 3 (mainly the
>> assertTrue
>> > for listname, password and email methods), when I tried tox -e
>> > py27-django1.7 -- postorius.tests.test_forms.UserNewTest, it says 0
>> tests
>> > ran in 0.001s
>> >
>> > 1) So I don't understand why the assertTrue validation is failing though
>> > all the inputs to the form is prefect? I talked to Aurelien and Abhliash
>> > and also followed (
>> >
>> https://docs.djangoproject.com/en/1.7/ref/forms/validation/#validating-fields-with-clean
>> )
>> > however it left me with the same situation.
>> >
>> > 2) If the tests run with tox then why do they not run when a particular
>> > testcase is tested?
>> >
>> > 3) I discussed this problem with Aurelien and he mentioned  "Form class
>> > shouldn't do anything in its __init__ function" however we do have
>> __inti__
>> > functions in our forms.py. So do we need to modify something there?
>> >
>> > --
>> > *Pranjal Yadav*
>> > _______________________________________________
>> > Mailman-Developers mailing list
>> > Mailman-Developers at python.org
>> > https://mail.python.org/mailman/listinfo/mailman-developers
>> > Mailman FAQ: http://wiki.list.org/x/AgA3
>> > Searchable Archives:
>> http://www.mail-archive.com/mailman-developers%40python.org/
>> > Unsubscribe:
>> https://mail.python.org/mailman/options/mailman-developers/raj.abhilash1%40gmail.com
>> >
>> > Security Policy: http://wiki.list.org/x/QIA9
>>
>>
>>
>> --
>> thanks,
>> Abhilash Raj
>>
>
>
>
> --
>
> *Pranjal Yadav*
>
> *IIT Kharagpur*
>



-- 

*Pranjal Yadav*

*IIT Kharagpur*


More information about the Mailman-Developers mailing list