Skip to content

Commit 1eafae0

Browse files
echedey-lsAdamRJensenkandersolar
authored
[MAINT]: Remove tests from wheel distro (#2277)
* Move files only used in tests to `pvlib/tests/data` * Attemp # 1 * Fine-tune inclusion via no-automatic data inclusion * Update v0.11.2.rst * Fix flake8 warnings * Update docs/sphinx/source/whatsnew/v0.11.2.rst Co-authored-by: Adam R. Jensen <[email protected]> * Flatten the tests dir out of pvlib * fix CI * revert back to the 💩 CRLF * Update v0.7.2.rst * whatsnews * Update test_solcast.py --------- Co-authored-by: Adam R. Jensen <[email protected]> Co-authored-by: Kevin Anderson <[email protected]>
1 parent 8bc594c commit 1eafae0

File tree

121 files changed

+179
-129
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+179
-129
lines changed

.github/workflows/pytest-remote-data.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ jobs:
100100
SOLARANYWHERE_API_KEY: ${{ secrets.SOLARANYWHERE_API_KEY }}
101101
BSRN_FTP_USERNAME: ${{ secrets.BSRN_FTP_USERNAME }}
102102
BSRN_FTP_PASSWORD: ${{ secrets.BSRN_FTP_PASSWORD }}
103-
run: pytest pvlib/tests/iotools --cov=./ --cov-report=xml --remote-data
103+
run: pytest tests/iotools --cov=./ --cov-report=xml --remote-data
104104

105105
- name: Upload coverage to Codecov
106106
if: matrix.python-version == 3.9 && matrix.suffix == ''

.github/workflows/pytest.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
shell: bash -l {0} # necessary for conda env to be active
8080
run: |
8181
# ignore iotools; those tests are run in a separate workflow
82-
pytest pvlib --cov=./ --cov-report=xml --ignore=pvlib/tests/iotools
82+
pytest tests --cov=./ --cov-report=xml --ignore=tests/iotools
8383
8484
- name: Upload coverage to Codecov
8585
if: matrix.python-version == 3.9 && matrix.suffix == '' && matrix.os == 'ubuntu-latest' && matrix.environment-type == 'conda'

.gitignore

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ coverage.xml
8181

8282

8383
# Datafiles
84-
*.csv
85-
# Ignore some csv
86-
!pvlib/data/*.csv
84+
# Do not exclude data directories
85+
!pvlib/data/**
86+
!tests/data/**
8787

8888
# vi
8989
*.swp

codecov.yml

+6-5
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ flags:
1414
core:
1515
paths:
1616
- pvlib/
17+
- tests/
1718
- '!pvlib/iotools/'
18-
- '!pvlib/tests/iotools/'
19+
- '!tests/iotools/'
1920
carryforward: false
2021

2122
remote-data:
2223
paths:
2324
- pvlib/iotools/
24-
- pvlib/tests/iotools
25+
- tests/iotools
2526
carryforward: true # if not run, use coverage from previous commit
2627

2728

@@ -47,15 +48,15 @@ coverage:
4748
tests-core:
4849
target: 95%
4950
paths:
50-
- 'pvlib/tests/.*'
51-
- '!pvlib/tests/iotools/.*'
51+
- 'tests/.*'
52+
- '!tests/iotools/.*'
5253
flags:
5354
- core
5455

5556
tests-remote-data:
5657
target: 95%
5758
paths:
58-
- 'pvlib/tests/iotools/.*'
59+
- 'tests/iotools/.*'
5960
flags:
6061
- remote-data
6162

docs/sphinx/source/contributing/testing.rst

+3-3

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

+7

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

+1-1

pyproject.toml

+9-1
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,22 @@ all = ["pvlib[test,optional,doc]"]
8585
Documentation = "https://pvlib-python.readthedocs.io/"
8686
"Source Code" = "https://github.com/pvlib/pvlib-python"
8787

88+
[tool.setuptools]
89+
# do not include all non-python files in the bdist by default, but select them manually
90+
# https://setuptools.pypa.io/en/latest/userguide/datafiles.html#interplay-between-these-keywords (2024-10-22)
91+
include-package-data = false # true by default
92+
8893
[tool.setuptools.packages.find]
8994
include = ["pvlib*"]
9095

96+
[tool.setuptools.package-data]
97+
pvlib = ["data/*"]
98+
9199
[tool.setuptools_scm]
92100

93101
[tool.pytest]
94102
junit_family = "xunit2"
95-
testpaths = "pvlib/tests"
103+
testpaths = "tests"
96104
# warning messages to suppress from pytest output. useful in cases
97105
# where a dependency hasn't addressed a deprecation yet, and there's
98106
# nothing we can do to fix it ourselves.
File renamed without changes.
File renamed without changes.

pvlib/tests/bifacial/test_infinite_sheds.py renamed to tests/bifacial/test_infinite_sheds.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import numpy as np
66
import pandas as pd
77
from pvlib.bifacial import infinite_sheds
8-
from ..conftest import assert_series_equal
8+
from tests.conftest import assert_series_equal
99

1010
import pytest
1111

pvlib/tests/bifacial/test_pvfactors.py renamed to tests/bifacial/test_pvfactors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pandas as pd
22
from datetime import datetime
33
from pvlib.bifacial.pvfactors import pvfactors_timeseries
4-
from ..conftest import requires_pvfactors, assert_series_equal
4+
from tests.conftest import requires_pvfactors, assert_series_equal
55
import pytest
66

77

File renamed without changes.

pvlib/tests/conftest.py renamed to tests/conftest.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ def assert_frame_equal(left, right, **kwargs):
7070

7171
# commonly used directories in the tests
7272
TEST_DIR = Path(__file__).parent
73-
DATA_DIR = TEST_DIR.parent / 'data'
73+
PVLIB_DATA_DIR = Path(pvlib.__path__[0]) / 'data'
74+
TESTS_DATA_DIR = TEST_DIR / 'data'
7475

7576

7677
# pytest-rerunfailures variables
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

pvlib/tests/iotools/test_acis.py renamed to tests/iotools/test_acis.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
get_acis_prism, get_acis_nrcc, get_acis_mpe,
1010
get_acis_station_data, get_acis_available_stations
1111
)
12-
from ..conftest import RERUNS, RERUNS_DELAY, assert_frame_equal
12+
from tests.conftest import RERUNS, RERUNS_DELAY, assert_frame_equal
1313
from requests import HTTPError
1414

1515

pvlib/tests/iotools/test_bsrn.py renamed to tests/iotools/test_bsrn.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@
77
import os
88
import tempfile
99
from pvlib.iotools import read_bsrn, get_bsrn
10-
from ..conftest import (DATA_DIR, RERUNS, RERUNS_DELAY, assert_index_equal,
11-
requires_bsrn_credentials)
10+
from tests.conftest import (
11+
TESTS_DATA_DIR,
12+
RERUNS,
13+
RERUNS_DELAY,
14+
assert_index_equal,
15+
requires_bsrn_credentials,
16+
)
1217

1318

1419
@pytest.fixture(scope="module")
@@ -33,7 +38,7 @@ def expected_index():
3338
('bsrn-lr0100-pay0616.dat'),
3439
])
3540
def test_read_bsrn(testfile, expected_index):
36-
data, metadata = read_bsrn(DATA_DIR / testfile)
41+
data, metadata = read_bsrn(TESTS_DATA_DIR / testfile)
3742
assert_index_equal(expected_index, data.index)
3843
assert 'ghi' in data.columns
3944
assert 'dni_std' in data.columns
@@ -45,7 +50,7 @@ def test_read_bsrn(testfile, expected_index):
4550
def test_read_bsrn_logical_records(expected_index):
4651
# Test if logical records 0300 and 0500 are correct parsed
4752
# and that 0100 is not passed when not specified
48-
data, metadata = read_bsrn(DATA_DIR / 'bsrn-pay0616.dat.gz',
53+
data, metadata = read_bsrn(TESTS_DATA_DIR / 'bsrn-pay0616.dat.gz',
4954
logical_records=['0300', '0500'])
5055
assert_index_equal(expected_index, data.index)
5156
assert 'lwu' in data.columns
@@ -57,13 +62,13 @@ def test_read_bsrn_logical_records(expected_index):
5762
def test_read_bsrn_bad_logical_record():
5863
# Test if ValueError is raised if an unsupported logical record is passed
5964
with pytest.raises(ValueError, match='not in'):
60-
read_bsrn(DATA_DIR / 'bsrn-lr0100-pay0616.dat',
65+
read_bsrn(TESTS_DATA_DIR / 'bsrn-lr0100-pay0616.dat',
6166
logical_records=['dummy'])
6267

6368

6469
def test_read_bsrn_logical_records_not_found():
6570
# Test if an empty dataframe is returned if specified LRs are not present
66-
data, metadata = read_bsrn(DATA_DIR / 'bsrn-lr0100-pay0616.dat',
71+
data, metadata = read_bsrn(TESTS_DATA_DIR / 'bsrn-lr0100-pay0616.dat',
6772
logical_records=['0300', '0500'])
6873
assert data.empty # assert that the dataframe is empty
6974
assert 'uva_global' in data.columns

pvlib/tests/iotools/test_crn.py renamed to tests/iotools/test_crn.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
from numpy import dtype, nan
44
import pytest
55
from pvlib.iotools import crn
6-
from ..conftest import DATA_DIR, assert_frame_equal, assert_index_equal
6+
from tests.conftest import (
7+
TESTS_DATA_DIR,
8+
assert_frame_equal,
9+
assert_index_equal,
10+
)
711

812

913
@pytest.fixture
@@ -41,12 +45,12 @@ def dtypes():
4145

4246
@pytest.fixture
4347
def testfile():
44-
return DATA_DIR / 'CRNS0101-05-2019-AZ_Tucson_11_W.txt'
48+
return TESTS_DATA_DIR / 'CRNS0101-05-2019-AZ_Tucson_11_W.txt'
4549

4650

4751
@pytest.fixture
4852
def testfile_problems():
49-
return DATA_DIR / 'CRN_with_problems.txt'
53+
return TESTS_DATA_DIR / 'CRN_with_problems.txt'
5054

5155

5256
def test_read_crn(testfile, columns_mapped, dtypes):

pvlib/tests/iotools/test_epw.py renamed to tests/iotools/test_epw.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import pytest
22

33
from pvlib.iotools import epw
4-
from ..conftest import DATA_DIR, RERUNS, RERUNS_DELAY
4+
from tests.conftest import TESTS_DATA_DIR, RERUNS, RERUNS_DELAY
55

6-
epw_testfile = DATA_DIR / 'NLD_Amsterdam062400_IWEC.epw'
6+
epw_testfile = TESTS_DATA_DIR / 'NLD_Amsterdam062400_IWEC.epw'
77

88

99
def test_read_epw():

pvlib/tests/iotools/test_midc.py renamed to tests/iotools/test_midc.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import pytz
44

55
from pvlib.iotools import midc
6-
from ..conftest import DATA_DIR, RERUNS, RERUNS_DELAY
6+
from tests.conftest import TESTS_DATA_DIR, RERUNS, RERUNS_DELAY
77

88

99
@pytest.fixture
@@ -17,10 +17,10 @@ def test_mapping():
1717
}
1818

1919

20-
MIDC_TESTFILE = DATA_DIR / 'midc_20181014.txt'
21-
MIDC_RAW_TESTFILE = DATA_DIR / 'midc_raw_20181018.txt'
20+
MIDC_TESTFILE = TESTS_DATA_DIR / 'midc_20181014.txt'
21+
MIDC_RAW_TESTFILE = TESTS_DATA_DIR / 'midc_raw_20181018.txt'
2222
MIDC_RAW_SHORT_HEADER_TESTFILE = (
23-
DATA_DIR / 'midc_raw_short_header_20191115.txt')
23+
TESTS_DATA_DIR / 'midc_raw_short_header_20191115.txt')
2424

2525
# TODO: not used, remove?
2626
# midc_network_testfile = ('https://midcdmz.nrel.gov/apps/data_api.pl'

pvlib/tests/iotools/test_panond.py renamed to tests/iotools/test_panond.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
"""
44

55
from pvlib.iotools import read_panond
6-
from pvlib.tests.conftest import DATA_DIR
76

8-
PAN_FILE = DATA_DIR / 'ET-M772BH550GL.PAN'
9-
OND_FILE = DATA_DIR / 'CPS SCH275KTL-DO-US-800-250kW_275kVA_1.OND'
7+
from tests.conftest import TESTS_DATA_DIR
8+
9+
PAN_FILE = TESTS_DATA_DIR / 'ET-M772BH550GL.PAN'
10+
OND_FILE = TESTS_DATA_DIR / 'CPS SCH275KTL-DO-US-800-250kW_275kVA_1.OND'
1011

1112

1213
def test_read_panond():

pvlib/tests/iotools/test_psm3.py renamed to tests/iotools/test_psm3.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,25 @@
22
test iotools for PSM3
33
"""
44

5-
import os
65
from pvlib.iotools import psm3
7-
from ..conftest import DATA_DIR, RERUNS, RERUNS_DELAY, assert_index_equal
6+
from tests.conftest import (
7+
TESTS_DATA_DIR,
8+
RERUNS,
9+
RERUNS_DELAY,
10+
assert_index_equal,
11+
)
812
import numpy as np
913
import pandas as pd
1014
import pytest
15+
import os
1116
from requests import HTTPError
1217
from io import StringIO
1318
import warnings
14-
from pvlib._deprecation import pvlibDeprecationWarning
1519

16-
TMY_TEST_DATA = DATA_DIR / 'test_psm3_tmy-2017.csv'
17-
YEAR_TEST_DATA = DATA_DIR / 'test_psm3_2017.csv'
18-
YEAR_TEST_DATA_5MIN = DATA_DIR / 'test_psm3_2019_5min.csv'
19-
MANUAL_TEST_DATA = DATA_DIR / 'test_read_psm3.csv'
20+
TMY_TEST_DATA = TESTS_DATA_DIR / 'test_psm3_tmy-2017.csv'
21+
YEAR_TEST_DATA = TESTS_DATA_DIR / 'test_psm3_2017.csv'
22+
YEAR_TEST_DATA_5MIN = TESTS_DATA_DIR / 'test_psm3_2019_5min.csv'
23+
MANUAL_TEST_DATA = TESTS_DATA_DIR / 'test_read_psm3.csv'
2024
LATITUDE, LONGITUDE = 40.5137, -108.5449
2125
METADATA_FIELDS = [
2226
'Source', 'Location ID', 'City', 'State', 'Country', 'Latitude',

0 commit comments

Comments
 (0)