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()
  • 相关阅读:
    BZOJ3527: [Zjoi2014]力(FFT)
    NOIP 2018游记
    BZOJ2763: [JLOI2011]飞行路线(分层图 最短路)
    11.7NOIP模拟赛解题报告
    交互体验之产品的文案
    关于java.lang.NoClassDefFoundError: com/sun/mail/util/LineInputStream解决办法
    [置顶] android 与JavaScript的互相调用
    linux系统的文件类型学习
    VS2012 开发SharePoint 2013 声明式workflow action(activity)之 HelloWorld
    js判断浏览器类型 js判断ie6不执行
  • 原文地址:https://www.cnblogs.com/jpr-ok/p/9171915.html
Copyright © 2011-2022 走看看