test_logout.py 993 Bytes
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import unittest
import urllib3
from commons.api.login import login
from commons.api.logout import logout
from commons import common as com
from commons.MySession import my
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
li=login()
lo=logout()

class test_logout(unittest.TestCase):
    "新增登记接口"
    @classmethod
    def setUpClass(cls):
        #通过登录接口获取session
        cls.se=li.login_session("hz_wenze", "111111")

    @unittest.case_mark(my.mark())
    def test_logout_01(self):
        "成功登出账户"
        re=lo.post(self.se, "user03")
        print(re.json())
        #响应断言
        self.assertEqual(re.status_code, 200)
        self.assertTrue("'code':'200'" in str(re.json()).replace(" ",""))
        
    @classmethod
    def tearDownClass(cls):
        cls.se.close()



if __name__ == "__main__":
    unittest.main(verbosity=2)

#     com.run_one(test_logout("test_01_logout"))