On Tue, 2008-09-09 at 20:25 +0200, Sven Richter wrote:
> i was playing around with unittests and found the
> failUnlessRaises(excClass, callableObj) Method.
> If i understand it right the Method catches Exceptions
> that are thrown by django.
>
> I tried to send a post to a register form with:
> res = Client().post('/register/', {data}) which
> works so far.
>
> Now i want to catch an Error, in this special case
> the error that is thrown if i forget a field,
> f.e. the password field.
> So i want to catch the "forgot-password-field-error".
>
> Now my question is, where can i find the exceptions
> i can catch? Meaning where are they described?
I was looking around the net cause i am afraid i cannot
sleep if i dont solve it tonight :D
At least i am more confused now.
I found an example for a unittest which uses
failUnlessRaises():
def raises_error(*args, **kwds):
print args, kwds
raise ValueError('Invalid value: ' + str(args) + str(kwds))
class ExceptionTest(unittest.TestCase):
def testFailUnlessRaises(self):
self.failUnlessRaises(ValueError, raises_error, 'a', b='c')
If i understand that right i have to submit the values
to the method raises_error from my testmethod which i want to check.
I am more confused now. How can i submit a post request with
given data to a method? In this case the raises_error method?
And how can i catch the error that a form field has to be
filled with some data?
At least i am questioning myself if failUnlessRaises
is available in django the way i want to use it.
So i am wondering how i can achieve to test
a form to throw an error?
Greetings
Sv
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---