[Flask + Redis] python learning Chapter 1 - 7.0 assertions database test learning redis

assert assert 

DEF div (num1, num2):
     # assert 
    the Assert isinstance (num1, int), " the value of the wrong type " 
    the Assert isinstance (num2, int), " the value of the wrong type " 
    the Assert ! num2 = 0, " the divisor is not 0 " 
    return num1 / num2 


IF  the __name__ == ' __main__ ' :
     Print (div (100, 0))

  

Unit testing unittest

1, classes need to inherit unittest.TestCase 

2, the test function must begin with a test  

3, setUp () before starting the test method tearDown method ends 

 

self.assert isinstance (num, int), "make a mistake"

self.assertIn ( "errcode", json_dict, "not acquired return data")

self.assertEqual (errcode, -2, "return error status code")

 

redis NOsql database 

Guess you like

Origin www.cnblogs.com/oscarli/p/12088968.html