Skip to content

Commit 565dfd3

Browse files
committed
Fix pandas 1.0.5 tests
1 parent 0d9166a commit 565dfd3

2 files changed

Lines changed: 11 additions & 13 deletions

File tree

tests/integration/test_plotting_integration.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,17 @@ def test_plumeplot_pre_calculated(plumeplot_scmrun, quantiles_plumes):
3737

3838

3939
def test_plumeplot_warns_dashes_without_lines(scm_run):
40-
with pytest.warns(UserWarning) as record:
40+
warn_msg = re.escape(
41+
"`dashes` was passed but no lines were plotted, the style "
42+
"settings will not be used"
43+
)
44+
with pytest.warns(UserWarning, match=warn_msg):
4145
scm_run.plumeplot(
4246
quantiles_plumes=(((0.17, 0.83), 0.7),),
4347
quantile_over="ensemble_member",
4448
dashes={"Surface Air Temperature Change": "--"},
4549
)
4650

47-
assert len(record) == 1
48-
assert record[0].message.args[0] == (
49-
"`dashes` was passed but no lines were plotted, the style "
50-
"settings will not be used"
51-
)
52-
5351

5452
def test_plumeplot_non_unique_lines(plumeplot_scmrun):
5553
quantile_over = "climate_model"

tests/unit/test_run.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,11 +1508,9 @@ def test_append(scm_run):
15081508

15091509
def 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))
15471546
def 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")
15761576
def 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")
15871588
def 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")
16051607
def 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

Comments
 (0)