@@ -533,7 +533,7 @@ def test_bad_init() -> None:
533
533
@pytest .mark .vcr
534
534
@pytest .mark .asyncio
535
535
async def test_ensure_sequential_run (caplog ) -> None :
536
- caplog .set_level (logging .DEBUG )
536
+ caplog .set_level (logging .DEBUG , logger = paperqa . clients . __name__ )
537
537
# were using a DOI that is NOT in crossref, but running the crossref client first
538
538
# we will ensure that both are run sequentially
539
539
@@ -551,14 +551,18 @@ async def test_ensure_sequential_run(caplog) -> None:
551
551
fields = ["doi" , "title" ],
552
552
)
553
553
assert details , "Should find the right DOI in the second client"
554
- record_indices = {"crossref" : - 1 , "semantic_scholar" : - 1 }
554
+ record_indices : dict [ str , list [ int ]] = {"crossref" : [] , "semantic_scholar" : [] }
555
555
for n , record in enumerate (caplog .records ):
556
+ if not record .name .startswith (paperqa .__name__ ): # Skip non-PQA logs
557
+ continue
556
558
if "CrossrefProvider" in record .msg :
557
- record_indices ["crossref" ] = n
559
+ record_indices ["crossref" ]. append ( n )
558
560
if "SemanticScholarProvider" in record .msg :
559
- record_indices ["semantic_scholar" ] = n
561
+ record_indices ["semantic_scholar" ].append (n )
562
+ assert record_indices ["crossref" ], "Crossref should run"
563
+ assert record_indices ["semantic_scholar" ], "Semantic Scholar should run"
560
564
assert (
561
- record_indices ["crossref" ] < record_indices ["semantic_scholar" ]
565
+ record_indices ["crossref" ][ - 1 ] < record_indices ["semantic_scholar" ][ - 1 ]
562
566
), "Crossref should run first"
563
567
564
568
non_clobbered_details = await client .query (
@@ -575,7 +579,7 @@ async def test_ensure_sequential_run(caplog) -> None:
575
579
@pytest .mark .vcr
576
580
@pytest .mark .asyncio
577
581
async def test_ensure_sequential_run_early_stop (caplog ) -> None :
578
- caplog .set_level (logging .DEBUG )
582
+ caplog .set_level (logging .DEBUG , logger = paperqa . clients . __name__ )
579
583
# now we should stop after hitting s2
580
584
async with aiohttp .ClientSession () as session :
581
585
client = DocMetadataClient (
@@ -591,21 +595,23 @@ async def test_ensure_sequential_run_early_stop(caplog) -> None:
591
595
fields = ["doi" , "title" ],
592
596
)
593
597
assert details , "Should find the right DOI in the second client"
594
- record_indices = {"crossref" : - 1 , "semantic_scholar" : - 1 , "early_stop" : - 1 }
598
+ record_indices : dict [str , list [int ]] = {
599
+ "crossref" : [],
600
+ "semantic_scholar" : [],
601
+ "early_stop" : [],
602
+ }
595
603
for n , record in enumerate (caplog .records ):
604
+ if not record .name .startswith (paperqa .__name__ ): # Skip non-PQA logs
605
+ continue
596
606
if "CrossrefProvider" in record .msg :
597
- record_indices ["crossref" ] = n
607
+ record_indices ["crossref" ]. append ( n )
598
608
if "SemanticScholarProvider" in record .msg :
599
- record_indices ["semantic_scholar" ] = n
609
+ record_indices ["semantic_scholar" ]. append ( n )
600
610
if "stopping early." in record .msg :
601
- record_indices ["early_stop" ] = n
602
- assert (
603
- record_indices ["crossref" ] == - 1
604
- ), "Crossref should be index -1 i.e. not found"
605
- assert (
606
- record_indices ["semantic_scholar" ] != - 1
607
- ), "Semantic Scholar should be found"
608
- assert record_indices ["early_stop" ] != - 1 , "We should stop early."
611
+ record_indices ["early_stop" ].append (n )
612
+ assert not record_indices ["crossref" ], "Crossref should not have run"
613
+ assert record_indices ["semantic_scholar" ], "Semantic Scholar should have run"
614
+ assert record_indices ["early_stop" ], "We should stop early"
609
615
610
616
611
617
@pytest .mark .vcr
0 commit comments