@@ -354,7 +354,7 @@ async def test_prepare_18_empty_result(self):
354
354
355
355
async def test_prepare_19_concurrent_calls (self ):
356
356
st = self .loop .create_task (self .con .fetchval (
357
- 'SELECT ROW(pg_sleep(0.02 ), 1)' ))
357
+ 'SELECT ROW(pg_sleep(0.03 ), 1)' ))
358
358
359
359
# Wait for some time to make sure the first query is fully
360
360
# prepared (!) and is now awaiting the results (!!).
@@ -367,20 +367,26 @@ async def test_prepare_19_concurrent_calls(self):
367
367
self .assertEqual (await st , (None , 1 ))
368
368
369
369
async def test_prepare_20_concurrent_calls (self ):
370
- for methname , val in [('fetch' , [(1 ,)]),
371
- ('fetchval' , 1 ),
372
- ('fetchrow' , (1 ,))]:
370
+ expected = ((None , 1 ),)
373
371
374
- meth = getattr (self .con , methname )
372
+ for methname , val in [('fetch' , [expected ]),
373
+ ('fetchval' , expected [0 ]),
374
+ ('fetchrow' , expected )]:
375
375
376
- vf = self .loop .create_task (meth ('SELECT 1' ))
377
- await asyncio .sleep (0 , loop = self .loop )
376
+ with self .subTest (meth = methname ):
378
377
379
- with self .assertRaisesRegex (asyncpg .InterfaceError ,
380
- 'another operation' ):
381
- await meth ('SELECT 2' )
378
+ meth = getattr (self .con , methname )
382
379
383
- self .assertEqual (await vf , val )
380
+ vf = self .loop .create_task (
381
+ meth ('SELECT ROW(pg_sleep(0.03), 1)' ))
382
+
383
+ await asyncio .sleep (0.01 , loop = self .loop )
384
+
385
+ with self .assertRaisesRegex (asyncpg .InterfaceError ,
386
+ 'another operation' ):
387
+ await meth ('SELECT 2' )
388
+
389
+ self .assertEqual (await vf , val )
384
390
385
391
async def test_prepare_21_errors (self ):
386
392
stmt = await self .con .prepare ('SELECT 10 / $1::int' )
0 commit comments