
from pprint import pprint

def status_code(result):
        code = result.status_code
        assert code == 200,"状态码报错,接口请求出错 错误码：%s != %s 返回内容：%s" % (code,200,result.content)
        print("状态码：{}".format(code))

def error_code(result):
        print(result)
        res = result.json()
        pprint(res)
        error_code = res.get("error")
        assert error_code == 0, "error码报错,接口请求出错 错误码：%s ！= %s 返回内容：%s" % (error_code, 0,res)
        print("error码：" + str(error_code))
        return res

def runtime(result):
        runtime = float(result.elapsed.total_seconds())
        assert runtime <= 10, "响应时间超时 超时时间：%s >= %s" % (runtime, 10)
        print("接口运行时长："+str(runtime))

def output_message(p, url):
        print("\n" + p + ": " + url)

def notnull(key):
        for i in key:
                if i in ["", None]:
                        raise Exception(i, "存在数据为空")
                else:
                        print("数据响应正常")









