【config.ini】
# -*- coding:utf-8 -*-
[Main_URL]
URL = http://wangzhandizhi
[UserIndexNew]
URL = user/index
Parameter = {"username":"xiaoming","password":"123456"}
# -*- coding:utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding("UTF-8")
import unittest
import requests
import configparser
import json
import time
import util
class Login(unittest.TestCase):
@classmethod
def setUpClass(self):
# 读取ini文件
self.cf = configparser.ConfigParser()
self.cf.read("Config.ini", encoding="utf-8-sig")
self.OK = "200"
self.Fail = u"接口访问失败"
pass
def setUp(self):
pass
def tearDown(self):
pass
@classmethod
def tearDownClass(self):
pass
def test_App_login(self):
data_json = json.loads(self.cf.get("UserIndexNew", "Parameter"))
self.login_object = requests.post(self.cf.get("Main_URL", "URL") + self.cf.get("UserIndexNew", "URL"),
"",
data_json)
self.json = self.login_object.json()
self.result = self.json["result"]
self.assertEqual(self.result, self.OK)
time.sleep(2)
pass
python接口自动化测试入门级简单易懂
最新推荐文章于 2024-07-13 13:34:34 发布