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