still not happy with unittest.failUnlessRaises
tim.peters at gmail.com
Sat Oct 9 17:53:18 CEST 2004
> while I got my own errors kind of sorted out now (I think), unittest
> still not behaves like it should.
> print 'this is expected to fail. The "Type" column is unique in the DB'
By "this is expected to fail", do you mean that the test is supposed
to fail, or that the test is supposed to pass by verifying that the
thing it's testing fails? "This" is ambiguous. I'll assume the
> self.failUnlessRaises(IntegrityError, self.failhelper(certs.Subcacert,
What you're actually testing here is that IntegrityError gets raised by
temp = self.failhelper(certs.Subcacert, self.ca_client_tmpl)
is evaluated outside the control of failUnlessRaises.
failUnlessRaises *calls* its second argument. If
on its own raises IntegrityError, and that's what you intended to
test, then you need to spell the test
You didn't show enough code so that a reader could guess the answers
to these questions.
> the docu (2.2) says:
> failUnlessRaises( exception, callable, ...)
> ...The test passes if exception is raised, is an error if another
> exception is raised, or fails if no exception is raised.
Yes. Note that the second argument is a callable object, and the
'...' consists of arguments to pass to the callable. So, e.g., the
fails, but the test
self.failUnlessRaises(ValueError, math.sqrt, -1)
More information about the Python-list