I run the following code with command "nosetests --with-html test_rest_api.py"
class Test_rest_api(unittest.TestCase):
def test_create_task_group(self):
data = {"name":"group2"}
response = ib_api.rest_request('POST', object_type="create_Test")
msg = json.loads(response.read())
self.assertTrue(response.status >= 200 and response.status < 300,msg)
if __name__ == '__main__':
unittest.main(verbosity=2)
If the case is failed i get the string which is in variable "msg", but if it the case is passed i don't get the message
Tried the solution as below,
self.assertTrue(response.status == 200 , msg)
print msg
This works but the issue here is if the case gets failed the message appears 2 times in the html report
Please suggest any good solution to handle the above case
I wound up customizing unittest's assert functions to get PASS messages in my logging.
Like this:
Then have your test cases inherit from
TestBaseinstead ofunittest.TestCase. Hope it helps!