MyGit
🚩收到GitHub仓库的更新通知

lundberg/respx

Fork: 38 Star: 512 (更新于 1970-01-01 00:00:00)

license: BSD-3-Clause

Language: Python .

Mock HTTPX with awesome request patterns and response side effects 🦋

最后发布版本: 0.20.2 ( 2023-07-21 07:05:54)

官方网址 GitHub网址

✨免费申请网站SSL证书,支持多域名和泛域名,点击查看

RESPX

RESPX - Mock HTTPX with awesome request patterns and response side effects.


tests codecov PyPi Version Python Versions

Documentation

Full documentation is available at lundberg.github.io/respx

QuickStart

RESPX is a simple, yet powerful, utility for mocking out the HTTPX, and HTTP Core, libraries.

Start by patching HTTPX, using respx.mock, then add request routes to mock responses.

import httpx
import respx

from httpx import Response


@respx.mock
def test_example():
    my_route = respx.get("https://example.org/").mock(return_value=Response(204))
    response = httpx.get("https://example.org/")
    assert my_route.called
    assert response.status_code == 204

Read the User Guide for a complete walk-through.

pytest + httpx

For a neater pytest experience, RESPX includes a respx_mock fixture for easy HTTPX mocking, along with an optional respx marker to fine-tune the mock settings.

import httpx
import pytest


def test_default(respx_mock):
    respx_mock.get("https://foo.bar/").mock(return_value=httpx.Response(204))
    response = httpx.get("https://foo.bar/")
    assert response.status_code == 204


@pytest.mark.respx(base_url="https://foo.bar")
def test_with_marker(respx_mock):
    respx_mock.get("/baz/").mock(return_value=httpx.Response(204))
    response = httpx.get("https://foo.bar/baz/")
    assert response.status_code == 204

Installation

Install with pip:

$ pip install respx

Requires Python 3.7+ and HTTPX 0.21+. See Changelog for older HTTPX compatibility.

最近版本更新:(数据更新于 1970-01-01 00:00:00)

2023-07-21 07:05:54 0.20.2

2022-11-19 01:03:03 0.20.1

2022-09-16 17:30:49 0.20.0

2022-09-14 18:03:04 0.19.3

2022-02-03 18:28:04 0.19.2

2022-01-10 18:13:43 0.19.1

2021-11-15 23:43:57 0.19.0

2021-10-22 15:26:07 0.18.2

2021-10-21 00:27:20 0.18.1

2021-10-14 21:38:06 0.18.0

主题(topics):

httpx, mock, pytest, testing

lundberg/respx同语言 Python最近更新仓库

2024-05-18 22:55:03 xtekky/gpt4free

2024-05-18 19:13:53 MetaCubeX/mihomo

2024-05-18 12:28:29 VikParuchuri/marker

2024-05-18 00:28:45 huggingface/transformers

2024-05-17 15:17:13 xorbitsai/inference

2024-05-17 15:13:07 microsoft/promptflow