Skip to content

Commit 1eb3085

Browse files
bump httpx test dependency (#630)
* bump httpx test dependency * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 33abffb commit 1eb3085

14 files changed

+71
-33
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ test = [
4949
"mypy ==1.13.0",
5050
"ruff ==0.7.1",
5151
"black ==24.10.0",
52-
"httpx >=0.23.3, <0.28.0",
52+
"httpx >=0.23.3, <0.29.0",
5353
"SQLAlchemy-Utils >=0.40.0, <0.42.0",
5454
"sqlmodel >=0.0.11, <0.1.0",
5555
"arrow >=1.2.3, <1.4.0",

tests/mongoengine/test_auth.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import mongoengine as me
44
import pytest
55
import pytest_asyncio
6-
from httpx import AsyncClient
6+
from httpx import ASGITransport, AsyncClient
77
from mongoengine import connect, disconnect
88
from starlette.applications import Starlette
99
from starlette.requests import Request
@@ -45,7 +45,9 @@ async def client(self):
4545
app = Starlette()
4646
admin.add_view(PostView(Post))
4747
admin.mount_to(app)
48-
async with AsyncClient(app=app, base_url="http://testserver") as c:
48+
async with AsyncClient(
49+
transport=ASGITransport(app=app), base_url="http://testserver"
50+
) as c:
4951
yield c
5052

5153
@pytest.mark.asyncio

tests/odmantic/test_async_engine.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import pytest
66
import pytest_asyncio
7-
from httpx import AsyncClient
7+
from httpx import ASGITransport, AsyncClient
88
from odmantic import AIOEngine, EmbeddedModel, Field, Model
99
from requests import Request
1010
from starlette.applications import Starlette
@@ -93,7 +93,9 @@ async def client(prepare_database, aio_engine: AIOEngine):
9393
app = Starlette()
9494
admin.add_view(UserView(User))
9595
admin.mount_to(app)
96-
async with AsyncClient(app=app, base_url="http://testserver") as c:
96+
async with AsyncClient(
97+
transport=ASGITransport(app=app), base_url="http://testserver"
98+
) as c:
9799
yield c
98100

99101

tests/odmantic/test_auth.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import pytest
44
import pytest_asyncio
5-
from httpx import AsyncClient
5+
from httpx import ASGITransport, AsyncClient
66
from odmantic import Field, Model, SyncEngine
77
from starlette.applications import Starlette
88
from starlette.requests import Request
@@ -36,7 +36,9 @@ async def client(self, sync_engine: SyncEngine):
3636
app = Starlette()
3737
admin.add_view(PostView(Post))
3838
admin.mount_to(app)
39-
async with AsyncClient(app=app, base_url="http://testserver") as c:
39+
async with AsyncClient(
40+
transport=ASGITransport(app=app), base_url="http://testserver"
41+
) as c:
4042
yield c
4143
sync_engine.remove(Post)
4244

tests/odmantic/test_sync_engine.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import pytest
44
import pytest_asyncio
5-
from httpx import AsyncClient
5+
from httpx import ASGITransport, AsyncClient
66
from odmantic import Model, Reference, SyncEngine
77
from starlette.applications import Starlette
88
from starlette_admin.contrib.odmantic import Admin, ModelView
@@ -48,7 +48,9 @@ async def client(prepare_database, sync_engine: SyncEngine):
4848
admin.add_view(ModelView(Author))
4949
admin.add_view(ModelView(Quote))
5050
admin.mount_to(app)
51-
async with AsyncClient(app=app, base_url="http://testserver") as c:
51+
async with AsyncClient(
52+
transport=ASGITransport(app=app), base_url="http://testserver"
53+
) as c:
5254
yield c
5355

5456

tests/sqla/test_async_engine.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import pytest
44
import pytest_asyncio
5-
from httpx import AsyncClient
5+
from httpx import ASGITransport, AsyncClient
66
from sqlalchemy import Column, Integer, String, select
77
from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession
88
from sqlalchemy.orm import declarative_base
@@ -78,7 +78,9 @@ async def client(engine: AsyncEngine):
7878
admin.add_view(ProductView(Product))
7979
app = Starlette()
8080
admin.mount_to(app)
81-
async with AsyncClient(app=app, base_url="http://testserver") as c:
81+
async with AsyncClient(
82+
transport=ASGITransport(app=app), base_url="http://testserver"
83+
) as c:
8284
yield c
8385

8486

tests/sqla/test_auth.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import pytest
44
import pytest_asyncio
5-
from httpx import AsyncClient
5+
from httpx import ASGITransport, AsyncClient
66
from sqlalchemy import Column, Integer, String
77
from sqlalchemy.engine import Engine
88
from sqlalchemy.orm import Session, declarative_base
@@ -58,7 +58,9 @@ async def client(self, engine):
5858
app = Starlette()
5959
admin.add_view(PostView(Post))
6060
admin.mount_to(app)
61-
async with AsyncClient(app=app, base_url="http://testserver") as c:
61+
async with AsyncClient(
62+
transport=ASGITransport(app=app), base_url="http://testserver"
63+
) as c:
6264
yield c
6365

6466
@pytest.mark.asyncio

tests/sqla/test_multiple_pks.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22
import pytest_asyncio
3-
from httpx import AsyncClient
3+
from httpx import ASGITransport, AsyncClient
44
from sqlalchemy import (
55
Boolean,
66
Column,
@@ -65,7 +65,9 @@ def app(admin: Admin):
6565

6666
@pytest_asyncio.fixture
6767
async def client(app):
68-
async with AsyncClient(app=app, base_url="http://testserver") as c:
68+
async with AsyncClient(
69+
transport=ASGITransport(app=app), base_url="http://testserver"
70+
) as c:
6971
yield c
7072

7173

tests/sqla/test_sqla_and_pydantic.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import pytest
55
import pytest_asyncio
6-
from httpx import AsyncClient
6+
from httpx import ASGITransport, AsyncClient
77
from pydantic import BaseModel, Field
88
from sqlalchemy import (
99
Boolean,
@@ -99,7 +99,9 @@ def app(admin: Admin):
9999

100100
@pytest_asyncio.fixture
101101
async def client(app):
102-
async with AsyncClient(app=app, base_url="http://testserver") as c:
102+
async with AsyncClient(
103+
transport=ASGITransport(app=app), base_url="http://testserver"
104+
) as c:
103105
yield c
104106

105107

tests/sqla/test_sqla_utils.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import pytest
1212
import pytest_asyncio
1313
from colour import Color
14-
from httpx import AsyncClient
14+
from httpx import ASGITransport, AsyncClient
1515
from sqlalchemy import Column, Integer, MetaData, event, select
1616
from sqlalchemy.engine import Engine
1717
from sqlalchemy.orm import Session, declarative_base
@@ -126,7 +126,9 @@ async def client(engine: Engine):
126126
admin.add_view(ModelView(Model))
127127
app = Starlette()
128128
admin.mount_to(app)
129-
async with AsyncClient(app=app, base_url="http://testserver") as c:
129+
async with AsyncClient(
130+
transport=ASGITransport(app=app), base_url="http://testserver"
131+
) as c:
130132
yield c
131133

132134

tests/sqla/test_sqlmodel.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import pytest
55
import pytest_asyncio
6-
from httpx import AsyncClient
6+
from httpx import ASGITransport, AsyncClient
77
from sqlalchemy.engine import Engine
88
from sqlmodel import Field, Relationship, Session, SQLModel, select
99
from starlette.applications import Starlette
@@ -63,7 +63,9 @@ def app(admin: Admin):
6363

6464
@pytest_asyncio.fixture
6565
async def client(app):
66-
async with AsyncClient(app=app, base_url="http://testserver") as c:
66+
async with AsyncClient(
67+
transport=ASGITransport(app=app), base_url="http://testserver"
68+
) as c:
6769
yield c
6870

6971

tests/sqla/test_sync_engine.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import pytest
77
import pytest_asyncio
88
import sqlalchemy_file as sf
9-
from httpx import AsyncClient
9+
from httpx import ASGITransport, AsyncClient
1010
from sqlalchemy import (
1111
Boolean,
1212
Column,
@@ -157,7 +157,9 @@ def app(admin: Admin):
157157

158158
@pytest_asyncio.fixture
159159
async def client(app):
160-
async with AsyncClient(app=app, base_url="http://testserver") as c:
160+
async with AsyncClient(
161+
transport=ASGITransport(app=app), base_url="http://testserver"
162+
) as c:
161163
yield c
162164

163165

tests/sqla/test_view_serialization.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import pytest
44
import pytest_asyncio
5-
from httpx import AsyncClient
5+
from httpx import ASGITransport, AsyncClient
66
from sqlalchemy import Boolean, Column, ForeignKey, String
77
from sqlalchemy.engine import Engine
88
from sqlalchemy.orm import Session, declarative_base, relationship
@@ -64,7 +64,9 @@ def app(engine: Engine):
6464

6565
@pytest_asyncio.fixture
6666
async def client(app):
67-
async with AsyncClient(app=app, base_url="http://testserver") as c:
67+
async with AsyncClient(
68+
transport=ASGITransport(app=app), base_url="http://testserver"
69+
) as c:
6870
yield c
6971

7072

tests/test_auth.py

+22-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import Optional, Sequence
33

44
import pytest
5-
from httpx import AsyncClient
5+
from httpx import ASGITransport, AsyncClient
66
from starlette.applications import Starlette
77
from starlette.requests import Request
88
from starlette_admin import (
@@ -104,7 +104,9 @@ async def test_auth_route(self):
104104
admin.mount_to(app)
105105
assert app.url_path_for("admin:login") == "/admin/login"
106106
assert app.url_path_for("admin:logout") == "/admin/logout"
107-
client = AsyncClient(app=app, base_url="http://testserver")
107+
client = AsyncClient(
108+
transport=ASGITransport(app=app), base_url="http://testserver"
109+
)
108110
response = await client.get("/admin/login")
109111
assert response.status_code == 200
110112
response = await client.get("/admin/", follow_redirects=False)
@@ -119,7 +121,9 @@ async def test_not_implemented_login(self):
119121
admin = BaseAdmin(auth_provider=AuthProvider())
120122
app = Starlette()
121123
admin.mount_to(app)
122-
client = AsyncClient(app=app, base_url="http://testserver")
124+
client = AsyncClient(
125+
transport=ASGITransport(app=app), base_url="http://testserver"
126+
)
123127
response = await client.post(
124128
"/admin/login",
125129
follow_redirects=False,
@@ -133,7 +137,9 @@ async def test_custom_login_path(self):
133137
app = Starlette()
134138
admin.mount_to(app)
135139
assert app.url_path_for("admin:login") == "/admin/custom-login"
136-
client = AsyncClient(app=app, base_url="http://testserver")
140+
client = AsyncClient(
141+
transport=ASGITransport(app=app), base_url="http://testserver"
142+
)
137143
response = await client.get("/admin/", follow_redirects=False)
138144
assert response.status_code == 303
139145
assert (
@@ -151,7 +157,9 @@ async def test_invalid_login(self):
151157
app = Starlette()
152158
admin.mount_to(app)
153159
assert app.url_path_for("admin:login") == "/admin/login"
154-
client = AsyncClient(app=app, base_url="http://testserver")
160+
client = AsyncClient(
161+
transport=ASGITransport(app=app), base_url="http://testserver"
162+
)
155163
data = {"username": "ad", "password": "invalid-password", "remember_me": "on"}
156164
response = await client.post("/admin/login", follow_redirects=False, data=data)
157165
assert "Ensure username has at least 03 characters" in response.text
@@ -165,7 +173,9 @@ async def test_valid_login(self):
165173
app = Starlette()
166174
admin.mount_to(app)
167175
assert app.url_path_for("admin:login") == "/admin/login"
168-
client = AsyncClient(app=app, base_url="http://testserver")
176+
client = AsyncClient(
177+
transport=ASGITransport(app=app), base_url="http://testserver"
178+
)
169179
response = await client.post(
170180
"/admin/login",
171181
data={"username": "admin", "password": "password", "remember_me": "on"},
@@ -200,7 +210,9 @@ def client(self, report_view):
200210
admin.add_view(report_view)
201211
admin.add_view(PostView)
202212
admin.mount_to(app)
203-
return AsyncClient(app=app, base_url="http://testserver")
213+
return AsyncClient(
214+
transport=ASGITransport(app=app), base_url="http://testserver"
215+
)
204216

205217
@pytest.mark.asyncio
206218
async def test_access_custom_view(self, client: AsyncClient):
@@ -317,7 +329,9 @@ def client(self):
317329
app = Starlette()
318330
admin.add_view(PostView)
319331
admin.mount_to(app)
320-
return AsyncClient(app=app, base_url="http://testserver")
332+
return AsyncClient(
333+
transport=ASGITransport(app=app), base_url="http://testserver"
334+
)
321335

322336
@pytest.mark.asyncio
323337
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)