Skip to content

Commit cc75255

Browse files
authored
Fix failing iotools tests (#2609)
* fix solargis test; expect new error message * sodapro: fix ME issue on old pandas introduced in #2600 * use atol in meteonorm tests
1 parent 31ccbb5 commit cc75255

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

tests/iotools/test_meteonorm.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ def test_get_meteonorm_training(
124124

125125
assert meta == expected_meta
126126
pd.testing.assert_index_equal(data.index, expected_meteonorm_index)
127-
pd.testing.assert_frame_equal(data.iloc[:12], expected_meteonorm_data)
127+
# meteonorm API only guarantees similar, not identical, results between
128+
# calls. so we allow a small amount of variation with atol.
129+
pd.testing.assert_frame_equal(data.iloc[:12], expected_meteonorm_data,
130+
check_exact=False, atol=1)
128131

129132

130133
@pytest.mark.remote_data
@@ -304,4 +307,7 @@ def test_get_meteonorm_tmy(
304307
map_variables=False,
305308
url=demo_url)
306309
assert meta == expected_meteonorm_tmy_meta
307-
pd.testing.assert_frame_equal(data.iloc[:12], expected_meteonorm_tmy_data)
310+
# meteonorm API only guarantees similar, not identical, results between
311+
# calls. so we allow a small amount of variation with atol.
312+
pd.testing.assert_frame_equal(data.iloc[:12], expected_meteonorm_tmy_data,
313+
check_exact=False, atol=1)

tests/iotools/test_sodapro.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121

2222
index_verbose = pd.date_range('2020-06-01 12', periods=4, freq='1min',
2323
tz='UTC')
24-
index_monthly = pd.date_range('2020-01-01', periods=4, freq='1ME')
24+
index_monthly = pd.to_datetime(['2020-01-31', '2020-02-29', '2020-03-31',
25+
'2020-04-30'])
2526

2627

2728
dtypes_mcclear_verbose = [

tests/iotools/test_solargis.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ def test_get_solargis_utc_start_timestamp(hourly_index_start_utc):
6565
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
6666
def test_get_solargis_http_error():
6767
# Test if HTTPError is raised if date outside range is specified
68-
with pytest.raises(requests.HTTPError, match="data coverage"):
68+
match = r"request fromDate .* is before the available start date"
69+
with pytest.raises(requests.HTTPError, match=match):
6970
_, _ = pvlib.iotools.get_solargis(
7071
latitude=48.61259, longitude=20.827079,
7172
start='1920-01-01', end='1920-01-01', # date outside range

0 commit comments

Comments
 (0)