Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] request json body is a list #824

Closed
moyanzhiyu opened this issue Dec 30, 2019 · 14 comments
Closed

[bug] request json body is a list #824

moyanzhiyu opened this issue Dec 30, 2019 · 14 comments
Assignees
Labels
bug Something isn't working

Comments

@moyanzhiyu
Copy link

问题描述

我们的新增接口只会返回status code,response中不会返回任何。用postman直接调用是返回的200.
但是使用httprunner的话就报错

版本信息

请提供如下版本信息:

  • 操作系统类型: [ Windows]
  • Python 版本 [3.6]
  • HttpRunner 版本 [2.1.2]

报错信息


Traceback (most recent call last):
ValueError: invalid literal for int() with base 16: b''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
http.client.IncompleteRead: IncompleteRead(0 bytes read)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
urllib3.exceptions.ProtocolError: ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
requests.exceptions.ChunkedEncodingError: ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))

image

@moyanzhiyu moyanzhiyu added the pending pending for confirmation label Dec 30, 2019
@debugtalk
Copy link
Member

@moyanzhiyu 你直接使用 requests 库去请求有报错么?

@moyanzhiyu
Copy link
Author

moyanzhiyu commented Jan 4, 2020

更新到最新版本 不会报错了 谢谢 但是现在最新版本 有另一个问题

teststeps:
-   name: /v1/klcs/classes/70/teachers
    request:
        headers:
        json:
        -   duty: 班主任
            teacher_id: 297
        method: POST

如果我直接在body里面放一个数组 就会报错 不让运行

ERROR [{'duty': '$duty_type0', 'teacher_id': '$teacher_id0'}] is not of type 'object'

Failed validating 'type' in schema[0]:
{'description': 'request body in json format', 'type': 'object'}

On instance:
[{'duty': '$duty_type0', 'teacher_id': '$teacher_id0'}]

但是之前版本可以跑的

@moyanzhiyu
Copy link
Author

我直接录制转换不管json还是yml都报错

@moyanzhiyu
Copy link
Author

moyanzhiyu commented Jan 4, 2020

{
    "config": {
        "name": "testcase description",
        "variables": {}
    },
    "teststeps": [
        {
            "name": "/v1/klcs/classes/70/teachers",
            "request": {
                "url": "",
                "method": "POST",
                "headers": {
                },
                "json": [
                    {
                        "teacher_id": 297,
                        "duty": "班主任"
                    }
                ]
            },
            "validate": [
                {
                    "eq": [
                        "status_code",
                        200
                    ]
                }
            ]
        }
    ]
}

@moyanzhiyu
Copy link
Author

@debugtalk

@debugtalk
Copy link
Member

@moyanzhiyu 你确定这个接口请求的 body 是一个 list 格式?

@debugtalk debugtalk changed the title 如果接口response没有,只返回status code的话,就会报错 [bug] request json body is a list Jan 6, 2020
@moyanzhiyu
Copy link
Author

嗯 确定是一个数组

@debugtalk debugtalk added bug Something isn't working and removed pending pending for confirmation labels Jun 5, 2020
@debugtalk
Copy link
Member

request json 已支持 list 类型。

@LeeJian
Copy link

LeeJian commented Jun 8, 2020

@debugtalk 可以再2.x版本同步修复这个问题么? 3.0由于httprunner的改动,之前的debugtalk文件需要从写

@debugtalk
Copy link
Member

@LeeJian v3 已经兼容支持 v2 的用例格式了。

@LeeJian
Copy link

LeeJian commented Jun 29, 2020

python3.8, hrun 3.1.1
`
from httprunner.api import HttpRunner

runner = HttpRunner()

runner.run(r'testcases/login/login.yml', mapping=mapping)
`
这样写会先提示httprunner.api 不存在, 然后去掉api, 会提示 run()没有mapping参数

@karencaiyuping
Copy link

更新到最新版本 不会报错了 谢谢 但是现在最新版本 有另一个问题

teststeps:
-   name: /v1/klcs/classes/70/teachers
    request:
        headers:
        json:
        -   duty: 班主任
            teacher_id: 297
        method: POST

如果我直接在body里面放一个数组 就会报错 不让运行

ERROR [{'duty': '$duty_type0', 'teacher_id': '$teacher_id0'}] is not of type 'object'

Failed validating 'type' in schema[0]:
{'description': 'request body in json format', 'type': 'object'}

On instance:
[{'duty': '$duty_type0', 'teacher_id': '$teacher_id0'}]

但是之前版本可以跑的

我跟你一样遇到了相同的问题,我是在2.及的版本遇到的

@karencaiyuping
Copy link

更新到最新版本 不会报错了 谢谢 但是现在最新版本 有另一个问题

teststeps:
-   name: /v1/klcs/classes/70/teachers
    request:
        headers:
        json:
        -   duty: 班主任
            teacher_id: 297
        method: POST

如果我直接在body里面放一个数组 就会报错 不让运行
ERROR [{'duty': '$duty_type0', 'teacher_id': '$teacher_id0'}] is not of type 'object'
Failed validating 'type' in schema[0]:
{'description': 'request body in json format', 'type': 'object'}
On instance:
[{'duty': '$duty_type0', 'teacher_id': '$teacher_id0'}]
但是之前版本可以跑的

我跟你一样遇到了相同的问题,我是在2.及的版本遇到的

你之前2.记得版本是可以的吗?也是一样这样写的吗,那你api那边是怎么写的呀

@wangtesting
Copy link

但是很多带参数的运行方式,随着不同版本,导致有的生效有的无效,很痛苦,不敢随意升级了都,也没有明确的些

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants