Skip to content

Commit 7be246e

Browse files
Use pytest remotedata (#896)
* enable pytest_remotedata for psm3 * add pytest_remotedata to test_pvgis.py * add @pytest.mark.remote_data to other network dependent tests * use up-to-date numpy, pandas * install netcdf4 from pip instead of conda * install pytest-remotedata from pip for conda 3.5 * readd @network to test_midc.py * add pytest-remotedata to py35-min for travis * add to what's new * point coverage at run with --remote-data * add --remote-data to travis run for coveralls to pickup * Revert "point coverage at run with --remote-data" This reverts commit e73eeb0. * Update docs/sphinx/source/whatsnew/v0.7.2.rst Co-Authored-By: Will Holmgren <[email protected]> * Update docs/sphinx/source/whatsnew/v0.7.2.rst Co-Authored-By: Will Holmgren <[email protected]> * Revert "install netcdf4 from pip instead of conda" This reverts commit 6fa8ecf. * fix linelength in what's new * add pytest-remotedata to Azure MacOS * move --remote-data tests to conda_linux * add remote_data decorators to tests requiring network * only install pytest-remotedata from pip, explain * fix tests directory name and url * document use of --remote-data flag in Contributing>Testing Co-authored-by: Will Holmgren <[email protected]>
1 parent 734fbba commit 7be246e

17 files changed

+52
-10
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ install:
6161
- pip install -e .
6262

6363
script:
64-
- pytest pvlib --cov=pvlib --cov-report term-missing
64+
- pytest pvlib --remote-data --cov=pvlib --cov-report term-missing
6565

6666
after_script:
6767
- if [[ $TASK == "coverage" ]]; then

azure-pipelines.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ jobs:
2626
versionSpec: '$(python.version)'
2727

2828
- script: |
29-
pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pytest-rerunfailures
29+
pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pytest-rerunfailures pytest-remotedata
3030
pip install -e .
31-
export NREL_API_KEY=$(nrelApiKey)
3231
pytest pvlib --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
3332
displayName: 'Test with pytest'
3433
@@ -77,7 +76,7 @@ jobs:
7776
- script: |
7877
source activate test_env
7978
export NREL_API_KEY=$(nrelApiKey)
80-
pytest pvlib --junitxml=junit/test-results.xml --cov --cov-report=xml --cov-report=html
79+
pytest pvlib --remote-data --junitxml=junit/test-results.xml --cov --cov-report=xml --cov-report=html
8180
displayName: 'pytest'
8281
# - script: |
8382
# source activate test_env
@@ -129,7 +128,6 @@ jobs:
129128
displayName: 'List installed dependencies'
130129
- script: |
131130
call activate test_env
132-
set NREL_API_KEY=$(nrelApiKey)
133131
pytest pvlib --junitxml=junit/test-results.xml
134132
displayName: 'pytest'
135133
- task: PublishTestResults@2
@@ -157,9 +155,8 @@ jobs:
157155
versionSpec: '$(python.version)'
158156

159157
- script: |
160-
pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pytest-rerunfailures
158+
pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pytest-rerunfailures pytest-remotedata
161159
pip install -e .
162-
export NREL_API_KEY=$(nrelApiKey)
163160
pytest pvlib --junitxml=junit/test-results.xml --cov=pvlib --cov-report=xml --cov-report=html
164161
displayName: 'Test with pytest'
165162

ci/requirements-py35-min.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ dependencies:
1616
- numpy==1.12.0
1717
- pandas==0.18.1
1818
- pytest-rerunfailures # conda version is >3.6
19+
- pytest-remotedata # conda package is 0.3.0, needs > 0.3.1

ci/requirements-py35.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ dependencies:
2727
- nrel-pysam>=2.0
2828
- pvfactors==1.0.1
2929
- pytest-rerunfailures # conda version is >3.6
30+
- pytest-remotedata # needs > 0.3.1

ci/requirements-py36.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dependencies:
1717
- pytest-cov
1818
- pytest-mock
1919
- pytest-rerunfailures
20+
- pytest-remotedata
2021
- pytest-timeout
2122
- python=3.6
2223
- pytz

ci/requirements-py37.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ dependencies:
1818
- pytest-mock
1919
- pytest-timeout
2020
- pytest-rerunfailures
21+
- pytest-remotedata
2122
- python=3.7
2223
- pytz
2324
- requests

docs/sphinx/source/contributing.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ Testing
262262
Developers **must** include comprehensive tests for any additions or
263263
modifications to pvlib. New unit test code should be placed in the
264264
corresponding test module in the
265-
`pvlib/test <https://github.com/pvlib/pvlib-python/tree/master/pvlib/test>`_
265+
`pvlib/tests <https://github.com/pvlib/pvlib-python/tree/master/pvlib/tests>`_
266266
directory.
267267

268268
A pull request will automatically run the tests for you on a variety of
@@ -298,6 +298,14 @@ location of a test failure. As described in :ref:`code-style`, pvlib
298298
code does not use ``print`` or ``logging`` calls, and this also applies
299299
to the test suite (with rare exceptions).
300300

301+
To include all network-dependent tests, include the ``--remote-data`` flag to
302+
your ``pytest`` call:
303+
304+
``pytest pvlib --remote-data``
305+
306+
And consider adding ``@pytest.mark.remote_data`` to any network dependent test
307+
you submit for a PR.
308+
301309
pvlib-python contains 3 "layers" of code: functions, PVSystem/Location,
302310
and ModelChain. Contributors will need to add tests that correspond to
303311
the layers that they modify.

docs/sphinx/source/whatsnew/v0.7.2.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@ Bug fixes
2525
passing ``tz=datetime.timezone.utc`` (:pull:`879`)
2626
* Fix documentation homepage title to "pvlib python" based on first heading on
2727
the page. (:pull:`890`) (:issue:`888`)
28+
* Implement `pytest-remotedata <https://github.com/astropy/pytest-remotedata>`_
29+
to increase test suite speed. Requires ``--remote-data`` pytest flag to
30+
execute data retrieval tests over a network.
2831
* Fix missing
2932
`0.7.0 what's new <https://pvlib-python.readthedocs.io/en/stable/whatsnew.html#v0-7-0-december-18-2019>`_
3033
entries about changes to ``PVSystem.pvwatts_ac``. Delete unreleased
3134
0.6.4 what's new file. (:issue:`898`)
3235
* Compatibility with cftime 1.1. (:issue:`895`)
3336

37+
3438
Documentation
3539
~~~~~~~~~~~~~
3640
* Add NumFOCUS affiliation to Sphinx documentation :pull:`862`
@@ -47,4 +51,4 @@ Contributors
4751
* Cameron T. Stark (:ghuser:`camerontstark`)
4852
* Will Holmgren (:ghuser:`wholmgren`)
4953
* Kevin Anderson (:ghuser:`kanderso-nrel`)
50-
* Karthikeyan Singaravelan (:ghuser:`tirkarthi`)
54+
* Karthikeyan Singaravelan (:ghuser:`tirkarthi`)

pvlib/tests/iotools/test_epw.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from pandas.util.testing import network
2+
import pytest
23

34
from pvlib.iotools import epw
45
from conftest import DATA_DIR
@@ -11,6 +12,7 @@ def test_read_epw():
1112

1213

1314
@network
15+
@pytest.mark.remote_data
1416
def test_read_epw_remote():
1517
url = 'https://energyplus.net/weather-download/europe_wmo_region_6/NLD//NLD_Amsterdam.062400_IWEC/NLD_Amsterdam.062400_IWEC.epw'
1618
epw.read_epw(url)

pvlib/tests/iotools/test_midc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def test_read_midc_var_mapping_as_arg(test_mapping):
6565

6666

6767
@network
68+
@pytest.mark.remote_data
6869
def test_read_midc_raw_data_from_nrel():
6970
start_ts = pd.Timestamp('20181018')
7071
end_ts = pd.Timestamp('20181019')

0 commit comments

Comments
 (0)