@@ -562,13 +562,12 @@ def test_none_returned_on_get_variant_call_with_experiment_not_found(self):
562
562
)
563
563
564
564
self .assertEqual (self .event_logger .log .call_count , 0 )
565
- with warnings . catch_warnings ( record = True ) as captured :
565
+ with self . assertLogs ( logger , logging . DEBUG ) as captured :
566
566
variant = decider .get_variant ("anything" )
567
567
568
- # can't test warning log only shows up only once if `decider.get_variant("anything")`
569
- # is called again due to bug in `catch_warnings` contextmanager
570
- # see https://github.com/python/cpython/issues/73858
571
- assert any ('Feature "anything" not found.' in str (x .message ) for x in captured )
568
+ assert any (
569
+ 'Feature "anything" not found.' in x .getMessage () for x in captured .records
570
+ )
572
571
self .assertEqual (variant , None )
573
572
574
573
# no exposures should be triggered
@@ -613,13 +612,12 @@ def test_none_returned_on_get_variant_without_expose_call_with_experiment_not_fo
613
612
)
614
613
615
614
self .assertEqual (self .event_logger .log .call_count , 0 )
616
- with warnings . catch_warnings ( record = True ) as captured :
615
+ with self . assertLogs ( logger , logging . DEBUG ) as captured :
617
616
variant = decider .get_variant_without_expose ("anything" )
618
617
619
- # can't test warning log only shows up only once if `decider.get_variant("anything")`
620
- # is called again due to bug in `catch_warnings` contextmanager
621
- # see https://github.com/python/cpython/issues/73858
622
- assert any ('Feature "anything" not found.' in str (x .message ) for x in captured )
618
+ assert any (
619
+ 'Feature "anything" not found.' in x .getMessage () for x in captured .records
620
+ )
623
621
self .assertEqual (variant , None )
624
622
625
623
# no exposures should be triggered
0 commit comments