How to use the respx.HTTPXMock function in respx

To help you get started, we’ve selected a few respx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lundberg / respx / tests / test_mock.py View on Github external
def test_deprecated():
    url = "https://foo.bar/"
    with respx.mock:
        respx.request("POST", url, status_code=201)
        with respx.HTTPXMock() as httpx_mock:
            httpx_mock.request("GET", url)
            response = httpx.post(url)
            assert response.status_code == 201
            response = httpx.get(url)
            assert response.status_code == 200
github lundberg / respx / tests / test_stats.py View on Github external
async def test_alias():
    async with respx.HTTPXMock(assert_all_called=False) as httpx_mock:
        url = "https://foo.bar/"
        request = httpx_mock.get(url, alias="foobar")
        assert "foobar" not in respx.aliases
        assert "foobar" in httpx_mock.aliases
        assert httpx_mock.aliases["foobar"].url == request.url
        assert httpx_mock["foobar"].url == request.url