Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test warnings #267

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading