Application python built-in function eval () in the test script assertion

Theory: https://www.runoob.com/python/python-func-eval.html

eval (): used to perform a string expression, and returns the value of the expression.

Application examples in practice:

from api.alert_info_controller.api_analysisType Import ApiAnalysisType 


class TestAnalysisType:
     DEF test_analysisType (Self): 
        RES = ApiAnalysisType () analysisType (). 
        STR = " res.json () [ 'Data'] IS None Not " 
        Assert res.status_code == 200 is
         Assert the eval (STR) # returns True or False in this case 

can be seen as a result of executing the test case pass

 

Guess you like

Origin www.cnblogs.com/wang-mengmeng/p/12593661.html
Recommended