MOOC (7) - case dependent, the configuration file is read json plurality of interface request -setup (4)

unittest based packaging and testing, setup initialize each function to be performed by embodiments own name for initialization []

Import the unittest
 from day_20200208_mooc.base.interface_request_class_2 Import RunMain 


class a testRequest (of unittest.TestCase): 
    @classmethod 
    DEF setUpClass (CLS):
         Pass 

    @classmethod 
    DEF tearDownClass (CLS):
         Pass 

    DEF the setUp (Self):
         # avoids the use case for each to write a instantiate 
        self.run = RunMain () 

    DEF tearDown (Self):
         Print ( " --------------- after each execution of test cases -------- -------- " ) 

    DEF TEST_1 (Self): 
        url ="http://apis.juhe.cn/rubbish/search"
        data = {"key": "6d9cc6b16d6cf63caded401b99c7311e",
                "q": "奶茶",
                "type": 2}
        res = self.run.run_main(url, "post", data)
        print(res)

    def test_2(self):
        url = "http://apis.juhe.cn/rubbish/search"
        data = {"key": "6d9cc6b16d6cf63caded401b99c7311e",
                "q": "苹果",
                "type": 2}
        res = self.run.run_main(url, "get", data)
        print(res)

 

Guess you like

Origin www.cnblogs.com/come202011/p/12313118.html