Testing with Unittest Python
Posted
by chrissygormley
on Stack Overflow
See other posts from Stack Overflow
or by chrissygormley
Published on 2010-05-20T14:37:59Z
Indexed on
2010/05/20
14:40 UTC
Read the original article
Hit count: 282
Hello,
I am runninig test's with Python Unittest. I am running tests but I want to do negative testing and I would like to test if a function throw's an exception, it passes but if no exception is thrown the test fail's. The script I have is:
try:
result = self.client.service.GetStreamUri(self.stream, self.token)
self.assertFalse
except suds.WebFault, e:
self.assertTrue
else:
self.assertTrue
This alway's passes as True even when the function work's perfectly. I have also tried various other way's including:
try:
result = self.client.service.GetStreamUri(self.stream, self.token)
self.assertFalse
except suds.WebFault, e:
self.assertTrue
except Exception, e:
self.assertTrue
Does anyone have any suggestions?
Thanks
© Stack Overflow or respective owner