pytest-http
Pytest发送HTTP请求
如何使用
- 安装
pytest-http
使用pip从github安装
pip install pytest-http
- 使用Fixture函数: http
def test_get(http): # 所有数据
res = http.get('https://httpbin.org/get?a=1&b=2')
print(res.text)
支持base_url配置
import pytest
@pytest.fixture
def base_url():
# you can use pytest-base-url instead
return 'https://httpbin.org'
def test_get(http): # 所有数据
res = http.get('/get?a=1&b=2')
print(res.text)
def test_post(http): # 所有数据
res = http.get('/post', data=dict(a=1, b=2))
print(res.text)
- 其他可用配置
import pytest
@pytest.fixture
def http_default_timeout():
return 10
@pytest.fixture
def http_default_headers():
return {'Authorization': 'Bearer xxx'}
@pytest.fixture
def http_default_params():
return {}
@pytest.fixture
def http_default_proxies():
return {}
- Email:
superhin@126.com - Blog:
博客园 韩志超 - 简书:
简书 韩志超
Metadata
Release files for pytest-http 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytest_http-0.1.1.tar.gz | 3.9 kB | Without provenance | Details for pytest_http-0.1.1.tar.gz |
Release files / pytest_http-0.1.1.tar.gz
| Download URL | pytest_http-0.1.1.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
86c1f7bb3e2872742a871666eb53f068a48ad2237f3ce5911b18a1eb2a60c2e8
|
|
BLAKE2b-256 checksum How to use checksums |
c0b0f4416a345027ab59c5d7284cf4e834b5d67ef6da795068eaee86ad292606
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.6
|
Security for pytest-http 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.