33from typing import TYPE_CHECKING , Callable
44
55import pytest
6- from pytest_asyncio import fixture as async_fixture
76
87from tests .misc .utils import fake
98from tests .models import (
@@ -41,7 +40,7 @@ async def create_user(async_session: AsyncSession, **fields):
4140 return user
4241
4342
44- @async_fixture ()
43+ @pytest . fixture ()
4544async def user_1 (async_session : AsyncSession ):
4645 user = build_user ()
4746 async_session .add (user )
@@ -52,7 +51,7 @@ async def user_1(async_session: AsyncSession):
5251 await async_session .commit ()
5352
5453
55- @async_fixture ()
54+ @pytest . fixture ()
5655async def user_2 (async_session : AsyncSession ):
5756 user = build_user ()
5857 async_session .add (user )
@@ -63,7 +62,7 @@ async def user_2(async_session: AsyncSession):
6362 await async_session .commit ()
6463
6564
66- @async_fixture ()
65+ @pytest . fixture ()
6766async def user_3 (async_session : AsyncSession ):
6867 user = build_user ()
6968 async_session .add (user )
@@ -81,7 +80,7 @@ async def build_user_bio(async_session: AsyncSession, user: User, **fields):
8180 return bio
8281
8382
84- @async_fixture ()
83+ @pytest . fixture ()
8584async def user_1_bio (async_session : AsyncSession , user_1 : User ) -> UserBio :
8685 return await build_user_bio (
8786 async_session ,
@@ -92,7 +91,7 @@ async def user_1_bio(async_session: AsyncSession, user_1: User) -> UserBio:
9291 )
9392
9493
95- @async_fixture ()
94+ @pytest . fixture ()
9695async def user_2_bio (async_session : AsyncSession , user_2 : User ) -> UserBio :
9796 return await build_user_bio (
9897 async_session ,
@@ -111,7 +110,7 @@ async def build_post(async_session: AsyncSession, user: User, **fields) -> Post:
111110 return post
112111
113112
114- @async_fixture ()
113+ @pytest . fixture ()
115114async def user_1_posts (async_session : AsyncSession , user_1 : User ) -> list [Post ]:
116115 posts = [
117116 Post (
@@ -130,7 +129,7 @@ async def user_1_posts(async_session: AsyncSession, user_1: User) -> list[Post]:
130129 return posts
131130
132131
133- @async_fixture ()
132+ @pytest . fixture ()
134133async def user_1_post (async_session : AsyncSession , user_1 : User ):
135134 post = Post (title = "post_for_u1" , user = user_1 )
136135 async_session .add (post )
@@ -144,7 +143,7 @@ async def user_1_post(async_session: AsyncSession, user_1: User):
144143 await async_session .commit ()
145144
146145
147- @async_fixture ()
146+ @pytest . fixture ()
148147async def user_2_posts (async_session : AsyncSession , user_2 : User ) -> list [Post ]:
149148 posts = [
150149 Post (
@@ -163,7 +162,7 @@ async def user_2_posts(async_session: AsyncSession, user_2: User) -> list[Post]:
163162 return posts
164163
165164
166- @async_fixture ()
165+ @pytest . fixture ()
167166async def user_1_comments_for_u2_posts (async_session : AsyncSession , user_1 , user_2_posts ):
168167 post_comments = [
169168 PostComment (
@@ -191,7 +190,7 @@ def user_1_post_for_comments(user_1_posts: list[Post]) -> Post:
191190 return user_1_posts [0 ]
192191
193192
194- @async_fixture ()
193+ @pytest . fixture ()
195194async def computer_1 (async_session : AsyncSession ):
196195 computer = Computer (name = "Halo" )
197196
@@ -205,7 +204,7 @@ async def computer_1(async_session: AsyncSession):
205204 await async_session .commit ()
206205
207206
208- @async_fixture ()
207+ @pytest . fixture ()
209208async def computer_2 (async_session : AsyncSession ):
210209 computer = Computer (name = "Nestor" )
211210
@@ -219,7 +218,7 @@ async def computer_2(async_session: AsyncSession):
219218 await async_session .commit ()
220219
221220
222- @async_fixture ()
221+ @pytest . fixture ()
223222async def computer_factory (async_session : AsyncSession ) -> Callable [[str | None ], Awaitable [Computer ]]:
224223 async def factory (name : str | None = None ) -> Computer :
225224 computer = Computer (name = name or fake .word ())
@@ -248,7 +247,7 @@ async def build_post_comment(
248247 return post_comment
249248
250249
251- @async_fixture ()
250+ @pytest . fixture ()
252251async def user_2_comment_for_one_u1_post (async_session : AsyncSession , user_2 , user_1_post_for_comments ):
253252 post = user_1_post_for_comments
254253 post_comment = PostComment (
@@ -267,7 +266,7 @@ async def user_2_comment_for_one_u1_post(async_session: AsyncSession, user_2, us
267266 await async_session .commit ()
268267
269268
270- @async_fixture ()
269+ @pytest . fixture ()
271270async def parent_1 (async_session : AsyncSession ):
272271 parent = Parent (
273272 name = "parent_1" ,
@@ -283,7 +282,7 @@ async def parent_1(async_session: AsyncSession):
283282 await async_session .commit ()
284283
285284
286- @async_fixture ()
285+ @pytest . fixture ()
287286async def parent_2 (async_session : AsyncSession ):
288287 parent = Parent (
289288 name = "parent_2" ,
@@ -299,7 +298,7 @@ async def parent_2(async_session: AsyncSession):
299298 await async_session .commit ()
300299
301300
302- @async_fixture ()
301+ @pytest . fixture ()
303302async def parent_3 (async_session : AsyncSession ):
304303 parent = Parent (
305304 name = "parent_3" ,
@@ -315,7 +314,7 @@ async def parent_3(async_session: AsyncSession):
315314 await async_session .commit ()
316315
317316
318- @async_fixture ()
317+ @pytest . fixture ()
319318async def child_1 (async_session : AsyncSession ):
320319 child = Child (
321320 name = "child_1" ,
@@ -331,7 +330,7 @@ async def child_1(async_session: AsyncSession):
331330 await async_session .commit ()
332331
333332
334- @async_fixture ()
333+ @pytest . fixture ()
335334async def child_2 (async_session : AsyncSession ):
336335 child = Child (
337336 name = "child_2" ,
@@ -347,7 +346,7 @@ async def child_2(async_session: AsyncSession):
347346 await async_session .commit ()
348347
349348
350- @async_fixture ()
349+ @pytest . fixture ()
351350async def child_3 (async_session : AsyncSession ):
352351 child = Child (
353352 name = "child_3" ,
@@ -363,7 +362,7 @@ async def child_3(async_session: AsyncSession):
363362 await async_session .commit ()
364363
365364
366- @async_fixture ()
365+ @pytest . fixture ()
367366async def child_4 (async_session : AsyncSession ):
368367 child = Child (
369368 name = "child_4" ,
@@ -379,7 +378,7 @@ async def child_4(async_session: AsyncSession):
379378 await async_session .commit ()
380379
381380
382- @async_fixture ()
381+ @pytest . fixture ()
383382async def p1_c1_association (
384383 async_session : AsyncSession ,
385384 parent_1 : Parent ,
@@ -401,7 +400,7 @@ async def p1_c1_association(
401400 await async_session .commit ()
402401
403402
404- @async_fixture ()
403+ @pytest . fixture ()
405404async def p2_c1_association (
406405 async_session : AsyncSession ,
407406 parent_2 : Parent ,
@@ -423,7 +422,7 @@ async def p2_c1_association(
423422 await async_session .commit ()
424423
425424
426- @async_fixture ()
425+ @pytest . fixture ()
427426async def p1_c2_association (
428427 async_session : AsyncSession ,
429428 parent_1 : Parent ,
@@ -445,7 +444,7 @@ async def p1_c2_association(
445444 await async_session .commit ()
446445
447446
448- @async_fixture ()
447+ @pytest . fixture ()
449448async def p2_c2_association (
450449 async_session : AsyncSession ,
451450 parent_2 : Parent ,
@@ -467,7 +466,7 @@ async def p2_c2_association(
467466 await async_session .commit ()
468467
469468
470- @async_fixture ()
469+ @pytest . fixture ()
471470async def p2_c3_association (
472471 async_session : AsyncSession ,
473472 parent_2 : Parent ,
@@ -498,14 +497,14 @@ async def build_workplace(async_session: AsyncSession, **fields):
498497 return workplace
499498
500499
501- @async_fixture ()
500+ @pytest . fixture ()
502501async def workplace_1 (
503502 async_session : AsyncSession ,
504503):
505504 yield await build_workplace (async_session , name = "workplace_1" )
506505
507506
508- @async_fixture ()
507+ @pytest . fixture ()
509508async def workplace_2 (
510509 async_session : AsyncSession ,
511510):
0 commit comments