Testing with Unittest Python
- by chrissygormley
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