@@ -1508,11 +1508,9 @@ def test_append(scm_run):
15081508
15091509def test_append_exact_duplicates (scm_run ):
15101510 other = copy .deepcopy (scm_run )
1511- with warnings . catch_warnings ( record = True ) as mock_warn_taking_average :
1511+ with pytest . warns ( UserWarning ) :
15121512 scm_run .append (other , duplicate_msg = "warn" ).timeseries ()
15131513
1514- assert len (mock_warn_taking_average ) == 1 # test message elsewhere
1515-
15161514 assert_scmdf_almost_equal (scm_run , other , check_ts_names = False )
15171515
15181516
@@ -1543,6 +1541,7 @@ def test_append_duplicates_order_doesnt_matter(scm_run):
15431541 npt .assert_almost_equal (obs , exp )
15441542
15451543
1544+ @pytest .mark .filterwarnings ("ignore::DeprecationWarning" )
15461545@pytest .mark .parametrize ("duplicate_msg" , ("warn" , True , False ))
15471546def test_append_duplicate_times (test_append_scm_runs , duplicate_msg ):
15481547 base = test_append_scm_runs ["base" ]
@@ -1573,6 +1572,7 @@ def test_append_duplicate_times(test_append_scm_runs, duplicate_msg):
15731572 )
15741573
15751574
1575+ @pytest .mark .filterwarnings ("ignore::DeprecationWarning" )
15761576def test_append_doesnt_warn_if_continuous_times (test_append_scm_runs ):
15771577 join_year = 2011
15781578 base = test_append_scm_runs ["base" ].filter (year = range (1 , join_year ))
@@ -1584,6 +1584,7 @@ def test_append_doesnt_warn_if_continuous_times(test_append_scm_runs):
15841584 assert len (mock_warn_taking_average ) == 0
15851585
15861586
1587+ @pytest .mark .filterwarnings ("ignore::DeprecationWarning" )
15871588def test_append_doesnt_warn_if_different (test_append_scm_runs ):
15881589 base = test_append_scm_runs ["base" ].filter (scenario = "a_scenario" )
15891590 other = test_append_scm_runs ["base" ].filter (scenario = "a_scenario2" )
@@ -1602,17 +1603,16 @@ def test_append_duplicate_times_error_msg(scm_run):
16021603 scm_run .append (other , duplicate_msg = "junk" )
16031604
16041605
1606+ @pytest .mark .filterwarnings ("ignore::DeprecationWarning" )
16051607def test_append_inplace (scm_run ):
16061608 other = scm_run * 2
16071609
16081610 obs = scm_run .filter (scenario = "a_scenario2" ).timeseries ().squeeze ()
16091611 exp = [2 , 7 , 7 ]
16101612 npt .assert_almost_equal (obs , exp )
1611- with warnings . catch_warnings ( record = True ) as mock_warn_taking_average :
1613+ with pytest . warns ( UserWarning ): # test message elsewhere
16121614 scm_run .append (other , inplace = True , duplicate_msg = "warn" )
16131615
1614- assert len (mock_warn_taking_average ) == 1 # test message elsewhere
1615-
16161616 obs = scm_run .filter (scenario = "a_scenario2" ).timeseries ().squeeze ()
16171617 exp = [(2.0 + 4.0 ) / 2 , (7.0 + 14.0 ) / 2 , (7.0 + 14.0 ) / 2 ]
16181618 npt .assert_almost_equal (obs , exp )
0 commit comments