zoukankan      html  css  js  c++  java
  • 提示'HTTP消息不可读'

    1、提示下面的错误信息

    2、修改后的代码,费用接口

    import unittest
    import requests
    import json
    import HTMLTestRunner
    
    ur1 = 'http://172.31.20.18:81/api/fee-master-web/v1/feeInfo/AddFee'
    headers = {'Content-Type': 'application/json','Referer':'172.31.20.18:81'}
    data = {
        "id": "3920638622712832",
        "createUser": "admin",
        "feeCode": "3920638622712833",
        "cformula":"借款年利率*逾期利息",
        "createTime":"",
        "eformula":"@loan.assetCore.yearRate*@repayment.repayMon.overdueIni",
        "feeCategory":"11",
        "feeDesc":"通天塔",
        "feeName":"首金管理费61301",
        "feeTag":"通天塔",
        "feeType":"1",
        "feeWay":"0",
        "payCode":"1",
        "recCode":"2",
        "status":1
    }
    r = requests.post(url=ur1,json=data,headers=headers)
    repones = r.json()
    print(r.json())
    print(r.status_code)
    
    class DemoTest(unittest.TestCase):
    
        def test_1(self):
            self.assertEquals(r.status_code, 200)
            print('第一条case')
        def test_2(self):
            self.assertIn('True',repones)
            #self.assertIn('HTTP消息不可读', repones)
            print('第二条case')
        def test_3(self):
            print('第3条case')
    #调整缩进后就会不执行main
    if __name__ == '__main__':
        print("开始main")
        suite = unittest.TestSuite()
        suite.addTest(DemoTest('test_1'))
        suite.addTest(DemoTest('test_2'))
        suite.addTest(DemoTest('test_3'))
    
        filename = 'E:\test.html'
        fp = open(filename, 'wb+')
    #这里了引用写的是HtmlTestRunner,一直报错,找半天原因
        #runner = HTMLTestRunner.HTMLTestRunner(stream=fp, output='E:/test.html', report_title='test-results',
                                               #descriptions='第一个python unittest')
        #runner = HTMLTestRunner.HTMLTestRunner(stream=fp,report_title=u"test-results",descriptions=u"第一个python unittest")
        runner = HTMLTestRunner.HTMLTestRunner(stream=fp, title=u"这是我测试报告标题", description=u"这是我测试用例的描述")
    
        runner.run(suite)
    
        fp.close()
  • 相关阅读:
    Jaba_Web--JDBC 修改记录操作模板
    Jaba_Web--JDBC 查询记录操作模板
    Jaba_Web--JDBC 删除记录操作模板
    Java_Web--JDBC 增加记录操作模板
    C语言编程入门题目--No.15
    C语言编程入门题目--No.13
    C语言编程入门题目--No.14
    C语言编程入门题目--No.12
    C语言编程入门题目--No.10
    C语言编程入门题目--No.11
  • 原文地址:https://www.cnblogs.com/jpr-ok/p/9171915.html
Copyright © 2011-2022 走看看