Skip to content

Commit

Permalink
Fix test warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
lundberg committed Apr 2, 2024
1 parent 366dd0b commit 4abc14b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest

import respx
from respx.fixtures import session_event_loop as event_loop # noqa: F401
from respx.fixtures import session_event_loop # noqa: F401

pytest_plugins = ["pytester"]

Expand All @@ -23,7 +23,7 @@ async def my_mock():


@pytest.fixture(scope="session")
async def mocked_foo(event_loop): # noqa: F811
async def mocked_foo(session_event_loop): # noqa: F811
async with respx.mock(
base_url="https://foo.api/api/", using="httpcore"
) as respx_mock:
Expand All @@ -33,7 +33,7 @@ async def mocked_foo(event_loop): # noqa: F811


@pytest.fixture(scope="session")
async def mocked_ham(event_loop): # noqa: F811
async def mocked_ham(session_event_loop): # noqa: F811
async with respx.mock(base_url="https://ham.api", using="httpcore") as respx_mock:
respx_mock.get("/", name="index").respond(200)
yield respx_mock
8 changes: 3 additions & 5 deletions tests/test_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,18 +473,16 @@ def test_add_remove_targets():
assert len(HTTPCoreMocker.targets) == pre_add_count


async def test_proxies():
async def test_proxy():
with respx.mock:
respx.get("https://foo.bar/") % dict(json={"foo": "bar"})
with httpx.Client(proxies={"https://": "https://1.1.1.1:1"}) as client:
with httpx.Client(proxy="https://1.1.1.1:1") as client:
response = client.get("https://foo.bar/")
assert response.json() == {"foo": "bar"}

async with respx.mock:
respx.get("https://foo.bar/") % dict(json={"foo": "bar"})
async with httpx.AsyncClient(
proxies={"https://": "https://1.1.1.1:1"}
) as client:
async with httpx.AsyncClient(proxy="https://1.1.1.1:1") as client:
response = await client.get("https://foo.bar/")
assert response.json() == {"foo": "bar"}

Expand Down

0 comments on commit 4abc14b

Please sign in to comment.