Skip to content

Commit cbd6ba0

Browse files
authored
fix: suppress passlib caused pytest warnings and other session warnings (#518)
Suppress warnings caused by `passlib` during testing.
1 parent 907a1b7 commit cbd6ba0

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ filterwarnings = [
219219
"ignore::DeprecationWarning:google",
220220
"ignore::DeprecationWarning:websockets.connection",
221221
"ignore::DeprecationWarning:websockets.legacy",
222+
"ignore:Accessing argon2.__version__ is deprecated:DeprecationWarning:passlib.handlers.argon2",
222223
]
223224
markers = [
224225
"integration: SQLAlchemy integration tests",

tests/integration/test_loader_and_execution_options.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,11 @@ class CountryRepository(SQLAlchemySyncRepository[UUIDCountry]):
8080
france = UUIDCountry(name="France")
8181
db_session.add(usa)
8282
db_session.add(france)
83+
db_session.flush() # Ensure countries are in session before creating states
8384

84-
california = UUIDState(name="California", country=usa)
85-
oregon = UUIDState(name="Oregon", country=usa)
86-
ile_de_france = UUIDState(name="Île-de-France", country=france)
85+
california = UUIDState(name="California", country_id=usa.id)
86+
oregon = UUIDState(name="Oregon", country_id=usa.id)
87+
ile_de_france = UUIDState(name="Île-de-France", country_id=france.id)
8788

8889
repo = USStateRepository(session=db_session)
8990
repo.add(california)
@@ -202,10 +203,11 @@ class CountryRepository(SQLAlchemyAsyncRepository[BigIntCountry]):
202203
france = BigIntCountry(name="France")
203204
db_session.add(usa)
204205
db_session.add(france)
206+
await db_session.flush() # Ensure countries are in session before creating states
205207

206-
california = BigIntState(name="California", country=usa)
207-
oregon = BigIntState(name="Oregon", country=usa)
208-
ile_de_france = BigIntState(name="Île-de-France", country=france)
208+
california = BigIntState(name="California", country_id=usa.id)
209+
oregon = BigIntState(name="Oregon", country_id=usa.id)
210+
ile_de_france = BigIntState(name="Île-de-France", country_id=france.id)
209211

210212
repo = USStateRepository(session=db_session)
211213
await repo.add(california)
@@ -323,10 +325,11 @@ class CountryRepository(SQLAlchemySyncRepository[UUIDCountryTest]):
323325
france = UUIDCountryTest(name="France")
324326
db_session.add(usa)
325327
db_session.add(france)
328+
db_session.flush() # Ensure countries are in session before creating states
326329

327-
california = UUIDStateTest(name="California", country=usa)
328-
oregon = UUIDStateTest(name="Oregon", country=usa)
329-
ile_de_france = UUIDStateTest(name="Île-de-France", country=france)
330+
california = UUIDStateTest(name="California", country_id=usa.id)
331+
oregon = UUIDStateTest(name="Oregon", country_id=usa.id)
332+
ile_de_france = UUIDStateTest(name="Île-de-France", country_id=france.id)
330333

331334
repo = USStateRepository(session=db_session)
332335
repo.add(california)
@@ -421,10 +424,11 @@ class CountryRepository(SQLAlchemyAsyncRepository[BigIntCountryTest]):
421424
france = BigIntCountryTest(name="France")
422425
db_session.add(usa)
423426
db_session.add(france)
427+
await db_session.flush() # Ensure countries are in session before creating states
424428

425-
california = BigIntStateTest(name="California", country=usa)
426-
oregon = BigIntStateTest(name="Oregon", country=usa)
427-
ile_de_france = BigIntStateTest(name="Île-de-France", country=france)
429+
california = BigIntStateTest(name="California", country_id=usa.id)
430+
oregon = BigIntStateTest(name="Oregon", country_id=usa.id)
431+
ile_de_france = BigIntStateTest(name="Île-de-France", country_id=france.id)
428432

429433
repo = USStateRepository(session=db_session)
430434
await repo.add(california)

0 commit comments

Comments
 (0)