|
2 | 2 | import os |
3 | 3 |
|
4 | 4 | from pandas.util.testing import network |
| 5 | +import pytest |
| 6 | + |
| 7 | +from pvlib._deprecation import pvlibDeprecationWarning |
| 8 | +from pvlib.iotools import tmy |
| 9 | + |
| 10 | +from conftest import fail_on_pvlib_version |
| 11 | + |
5 | 12 |
|
6 | 13 | test_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) |
7 | 14 | tmy3_testfile = os.path.join(test_dir, '../data/703165TY.csv') |
8 | 15 | tmy2_testfile = os.path.join(test_dir, '../data/12839.tm2') |
9 | 16 |
|
10 | | -from pvlib import tmy |
| 17 | + |
| 18 | +@fail_on_pvlib_version('0.7') |
| 19 | +def test_deprecated_07(): |
| 20 | + with pytest.warns(pvlibDeprecationWarning): |
| 21 | + from pvlib.tmy import readtmy2 |
| 22 | + readtmy2(tmy2_testfile) |
| 23 | + with pytest.warns(pvlibDeprecationWarning): |
| 24 | + from pvlib.tmy import readtmy3 |
| 25 | + readtmy3(tmy3_testfile) |
11 | 26 |
|
12 | 27 |
|
13 | | -def test_readtmy3(): |
14 | | - tmy.readtmy3(tmy3_testfile) |
| 28 | +def test_read_tmy3(): |
| 29 | + tmy.read_tmy3(tmy3_testfile) |
| 30 | + |
15 | 31 |
|
16 | 32 | @network |
17 | | -def test_readtmy3_remote(): |
| 33 | +def test_read_tmy3_remote(): |
18 | 34 | url = 'http://rredc.nrel.gov/solar/old_data/nsrdb/1991-2005/data/tmy3/703165TYA.CSV' |
19 | | - tmy.readtmy3(url) |
20 | | - |
21 | | -def test_readtmy3_recolumn(): |
22 | | - data, meta = tmy.readtmy3(tmy3_testfile) |
| 35 | + tmy.read_tmy3(url) |
| 36 | + |
| 37 | + |
| 38 | +def test_read_tmy3_recolumn(): |
| 39 | + data, meta = tmy.read_tmy3(tmy3_testfile) |
23 | 40 | assert 'GHISource' in data.columns |
24 | | - |
25 | | -def test_readtmy3_norecolumn(): |
26 | | - data, meta = tmy.readtmy3(tmy3_testfile, recolumn=False) |
| 41 | + |
| 42 | + |
| 43 | +def test_read_tmy3_norecolumn(): |
| 44 | + data, meta = tmy.read_tmy3(tmy3_testfile, recolumn=False) |
27 | 45 | assert 'GHI source' in data.columns |
28 | | - |
29 | | -def test_readtmy3_coerce_year(): |
| 46 | + |
| 47 | + |
| 48 | +def test_read_tmy3_coerce_year(): |
30 | 49 | coerce_year = 1987 |
31 | | - data, meta = tmy.readtmy3(tmy3_testfile, coerce_year=coerce_year) |
| 50 | + data, meta = tmy.read_tmy3(tmy3_testfile, coerce_year=coerce_year) |
32 | 51 | assert (data.index.year == 1987).all() |
33 | | - |
34 | | -def test_readtmy3_no_coerce_year(): |
| 52 | + |
| 53 | + |
| 54 | +def test_read_tmy3_no_coerce_year(): |
35 | 55 | coerce_year = None |
36 | | - data, meta = tmy.readtmy3(tmy3_testfile, coerce_year=coerce_year) |
| 56 | + data, meta = tmy.read_tmy3(tmy3_testfile, coerce_year=coerce_year) |
37 | 57 | assert 1997 and 1999 in data.index.year |
38 | | - |
39 | | -def test_readtmy2(): |
40 | | - tmy.readtmy2(tmy2_testfile) |
41 | | - |
| 58 | + |
| 59 | + |
| 60 | +def test_read_tmy2(): |
| 61 | + tmy.read_tmy2(tmy2_testfile) |
0 commit comments