Skip to main content

Fixture "http" for http requests

Project description

pytest-http

Languate - Python PyPI - License PyPI PyPI - Downloads

Pytest发送HTTP请求


如何使用

  1. 安装 pytest-http

使用pip从github安装

pip install pytest-http
  1. 使用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)
  1. 其他可用配置
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 {}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_http-0.1.1.tar.gz (3.9 kB view details)

Uploaded Source

File details

Details for the file pytest_http-0.1.1.tar.gz.

File metadata

  • Download URL: pytest_http-0.1.1.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.6

File hashes

Hashes for pytest_http-0.1.1.tar.gz
Algorithm Hash digest
SHA256 86c1f7bb3e2872742a871666eb53f068a48ad2237f3ce5911b18a1eb2a60c2e8
MD5 aba1350d4475d0f33ef52a2cdf15aaa9
BLAKE2b-256 c0b0f4416a345027ab59c5d7284cf4e834b5d67ef6da795068eaee86ad292606

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page