collect and show http requests elapsed time
Project description
pytest-requestselapsed
当前插件对 requests 库进行简单的封装使它成为一个 fixture 对象.
安装插件
pip3 install pytest-requestselapsed
测试用例
test_case.py
不需要导入 requests 库, 在测试函数入口声明使用 requests Fixture就具备使用 requests 库的能力.
def test_baidu(requests):
resp = requests.get("https://www.baidu.com")
assert resp.status_code < 400
def test_qq(requests):
resp = requests.get("https://weixin.qq.com/")
assert resp.status_code < 400
def test_taobao(requests):
resp = requests.get("https://www.taobao.com")
assert resp.status_code < 400
def test_bilibili(requests):
resp = requests.get("https://www.bilibili.com")
assert resp.status_code < 400
测试报告
-
默认表现
$ cd example/readme/ $ pytest ======================================= test session starts ======================================= platform linux -- Python 3.8.10, pytest-7.1.2, pluggy-1.0.0 rootdir: /home/zt/PycharmProjects/pytest-requestselapsed/example/readme plugins: requestselapsed-0.0.1 collected 4 items test_case.py .... [100%] ======================================== 4 passed in 1.44s ========================================
-
在控制台打印api响应报告
$ cd example/readme/ $ pytest --output-mode=console ============================================= test session starts ============================================= platform linux -- Python 3.8.10, pytest-7.1.2, pluggy-1.0.0 rootdir: /home/zt/PycharmProjects/pytest-requestselapsed/example/readme plugins: requestselapsed-0.0.1 collected 4 items test_case.py .... [100%] elapsed method url 0.690789 GET https://www.bilibili.com/?rt=V%2FymTlOu4ow%2Fy4xxNWPUZxCA8HpNf6nrCC8%2BjIwXT0M%3D 0.572896 GET https://www.bilibili.com/ 0.498390 GET https://www.baidu.com/ 0.387840 GET https://weixin.qq.com/ 0.159209 GET https://www.taobao.com/ ============================================== 4 passed in 1.58s ==============================================
-
在飞书群聊窗口打印api响应报告
$ cd example/readme/ $ pytest --output-mode=feishu --feishu-webhook-url=https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx ======================================= test session starts ======================================= platform linux -- Python 3.8.10, pytest-7.1.2, pluggy-1.0.0 rootdir: /home/zt/PycharmProjects/pytest-requestselapsed/example/readme plugins: requestselapsed-0.0.1 collected 4 items test_case.py .... [100%] ======================================== 4 passed in 1.44s ========================================
更多案例
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pytest-requestselapsed-0.0.3.tar.gz
.
File metadata
- Download URL: pytest-requestselapsed-0.0.3.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5885d5b53b073e6bfb09108a718b87a652732ac1f79d17ee1eee0c28bd57bd75 |
|
MD5 | c5ffdd7c59c9befe780d292db0673f4d |
|
BLAKE2b-256 | 84843b04f4da3e58c316bcfbe2c0fabfc1aa6aa30d3ccce01ff2cf34ad2d2678 |
File details
Details for the file pytest_requestselapsed-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: pytest_requestselapsed-0.0.3-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 181b39e60f8f8b2733354d9cba939f98d6c8750069f5f98a1f965f3132f6520d |
|
MD5 | eb1d39ce5f492c4c8878e492bc83fd4a |
|
BLAKE2b-256 | 549390512570eecf44da9194b9b0c6cb29d4b1c69d58f048792066d4da27463f |