Skip to content

Commit 71d9b0a

Browse files
committed
Flatten the tests dir out of pvlib
1 parent 692132d commit 71d9b0a

File tree

121 files changed

+413
-389
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

+413
-389
lines changed

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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 pvlib --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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ coverage.xml
8383
# Datafiles
8484
# Do not exclude data directories
8585
!pvlib/data/**
86-
!pvlib/tests/data/**
86+
!tests/data/**
8787

8888
# vi
8989
*.swp

codecov.yml

Lines changed: 6 additions & 5 deletions
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

Lines changed: 3 additions & 3 deletions

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

Lines changed: 1 addition & 1 deletion

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

Lines changed: 1 addition & 1 deletion

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ include-package-data = false # true by default
9292

9393
[tool.setuptools.packages.find]
9494
include = ["pvlib*"]
95-
exclude = ["pvlib.tests*"]
9695

9796
[tool.setuptools.package-data]
9897
pvlib = ["data/*"]
@@ -101,7 +100,7 @@ pvlib = ["data/*"]
101100

102101
[tool.pytest]
103102
junit_family = "xunit2"
104-
testpaths = "pvlib/tests"
103+
testpaths = "tests"
105104
# warning messages to suppress from pytest output. useful in cases
106105
# where a dependency hasn't addressed a deprecation yet, and there's
107106
# 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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def assert_frame_equal(left, right, **kwargs):
7070

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

7676

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import os
88
import tempfile
99
from pvlib.iotools import read_bsrn, get_bsrn
10-
from ..conftest import (
10+
from tests.conftest import (
1111
TESTS_DATA_DIR,
1212
RERUNS,
1313
RERUNS_DELAY,

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

Lines changed: 5 additions & 1 deletion
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 TESTS_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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22

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

66
epw_testfile = TESTS_DATA_DIR / 'NLD_Amsterdam062400_IWEC.epw'
77

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

Lines changed: 1 addition & 1 deletion
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 TESTS_DATA_DIR, RERUNS, RERUNS_DELAY
6+
from tests.conftest import TESTS_DATA_DIR, RERUNS, RERUNS_DELAY
77

88

99
@pytest.fixture

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"""
44

55
from pvlib.iotools import read_panond
6-
from pvlib.tests.conftest import TESTS_DATA_DIR
6+
7+
from tests.conftest import TESTS_DATA_DIR
78

89
PAN_FILE = TESTS_DATA_DIR / 'ET-M772BH550GL.PAN'
910
OND_FILE = TESTS_DATA_DIR / 'CPS SCH275KTL-DO-US-800-250kW_275kVA_1.OND'

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22
test iotools for PSM3
33
"""
44

5-
import os
65
from pvlib.iotools import psm3
7-
from ..conftest import TESTS_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

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

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,21 @@
1010
from pvlib.iotools import get_pvgis_tmy, read_pvgis_tmy
1111
from pvlib.iotools import get_pvgis_hourly, read_pvgis_hourly
1212
from pvlib.iotools import get_pvgis_horizon
13-
from ..conftest import (DATA_DIR, RERUNS, RERUNS_DELAY, assert_frame_equal,
14-
assert_series_equal)
13+
from tests.conftest import (
14+
TESTS_DATA_DIR,
15+
RERUNS,
16+
RERUNS_DELAY,
17+
assert_frame_equal,
18+
assert_series_equal,
19+
)
1520

1621

1722
# PVGIS Hourly tests
1823
# The test files are actual files from PVGIS where the data section have been
1924
# reduced to only a few lines
20-
testfile_radiation_csv = DATA_DIR / \
25+
testfile_radiation_csv = TESTS_DATA_DIR / \
2126
'pvgis_hourly_Timeseries_45.000_8.000_SA_30deg_0deg_2016_2016.csv'
22-
testfile_pv_json = DATA_DIR / \
27+
testfile_pv_json = TESTS_DATA_DIR / \
2328
'pvgis_hourly_Timeseries_45.000_8.000_SA2_10kWp_CIS_5_2a_2013_2014.json'
2429

2530
index_radiation_csv = \
@@ -304,12 +309,14 @@ def test_read_pvgis_hourly_empty_file():
304309
# PVGIS TMY tests
305310
@pytest.fixture
306311
def expected():
307-
return pd.read_csv(DATA_DIR / 'pvgis_tmy_test.csv', index_col='time(UTC)')
312+
return pd.read_csv(
313+
TESTS_DATA_DIR / "pvgis_tmy_test.csv", index_col="time(UTC)"
314+
)
308315

309316

310317
@pytest.fixture
311318
def userhorizon_expected():
312-
return pd.read_json(DATA_DIR / 'tmy_45.000_8.000_userhorizon.json')
319+
return pd.read_json(TESTS_DATA_DIR / 'tmy_45.000_8.000_userhorizon.json')
313320

314321

315322
@pytest.fixture
@@ -348,7 +355,7 @@ def epw_meta():
348355

349356
@pytest.fixture
350357
def meta_expected():
351-
with (DATA_DIR / 'pvgis_tmy_meta.json').open() as f:
358+
with (TESTS_DATA_DIR / 'pvgis_tmy_meta.json').open() as f:
352359
return json.load(f)
353360

354361

@@ -550,7 +557,7 @@ def test_get_pvgis_map_variables(pvgis_tmy_mapped_columns):
550557
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
551558
def test_read_pvgis_horizon():
552559
pvgis_data, _ = get_pvgis_horizon(35.171051, -106.465158)
553-
horizon_data = pd.read_csv(DATA_DIR / 'test_read_pvgis_horizon.csv',
560+
horizon_data = pd.read_csv(TESTS_DATA_DIR / 'test_read_pvgis_horizon.csv',
554561
index_col=0)
555562
horizon_data = horizon_data['horizon_elevation']
556563
assert_series_equal(pvgis_data, horizon_data)
@@ -564,14 +571,14 @@ def test_read_pvgis_horizon_invalid_coords():
564571

565572

566573
def test_read_pvgis_tmy_map_variables(pvgis_tmy_mapped_columns):
567-
fn = DATA_DIR / 'tmy_45.000_8.000_2005_2023.json'
574+
fn = TESTS_DATA_DIR / 'tmy_45.000_8.000_2005_2023.json'
568575
actual, _, _, _ = read_pvgis_tmy(fn, map_variables=True)
569576
assert all(c in pvgis_tmy_mapped_columns for c in actual.columns)
570577

571578

572579
def test_read_pvgis_tmy_json(expected, month_year_expected, inputs_expected,
573580
meta_expected):
574-
fn = DATA_DIR / 'tmy_45.000_8.000_2005_2023.json'
581+
fn = TESTS_DATA_DIR / 'tmy_45.000_8.000_2005_2023.json'
575582
# infer outputformat from file extensions
576583
pvgis_data = read_pvgis_tmy(fn, map_variables=False)
577584
_compare_pvgis_tmy_json(expected, month_year_expected, inputs_expected,
@@ -588,7 +595,7 @@ def test_read_pvgis_tmy_json(expected, month_year_expected, inputs_expected,
588595

589596

590597
def test_read_pvgis_tmy_epw(expected, epw_meta):
591-
fn = DATA_DIR / 'tmy_45.000_8.000_2005_2023.epw'
598+
fn = TESTS_DATA_DIR / 'tmy_45.000_8.000_2005_2023.epw'
592599
# infer outputformat from file extensions
593600
pvgis_data = read_pvgis_tmy(fn, map_variables=False)
594601
_compare_pvgis_tmy_epw(expected, epw_meta, pvgis_data)
@@ -603,7 +610,7 @@ def test_read_pvgis_tmy_epw(expected, epw_meta):
603610

604611
def test_read_pvgis_tmy_csv(expected, month_year_expected, inputs_expected,
605612
meta_expected, csv_meta):
606-
fn = DATA_DIR / 'tmy_45.000_8.000_2005_2023.csv'
613+
fn = TESTS_DATA_DIR / 'tmy_45.000_8.000_2005_2023.csv'
607614
# infer outputformat from file extensions
608615
pvgis_data = read_pvgis_tmy(fn, map_variables=False)
609616
_compare_pvgis_tmy_csv(expected, month_year_expected, inputs_expected,
@@ -620,7 +627,7 @@ def test_read_pvgis_tmy_csv(expected, month_year_expected, inputs_expected,
620627

621628

622629
def test_read_pvgis_tmy_basic(expected, meta_expected):
623-
fn = DATA_DIR / 'tmy_45.000_8.000_2005_2023.txt'
630+
fn = TESTS_DATA_DIR / 'tmy_45.000_8.000_2005_2023.txt'
624631
# XXX: can't infer outputformat from file extensions for basic
625632
with pytest.raises(ValueError, match="pvgis format 'txt' was unknown"):
626633
read_pvgis_tmy(fn, map_variables=False)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import pytest
99

1010
from pvlib.iotools import sodapro
11-
from ..conftest import TESTS_DATA_DIR, assert_frame_equal
11+
from tests.conftest import TESTS_DATA_DIR, assert_frame_equal
1212

1313

1414
testfile_mcclear_verbose = TESTS_DATA_DIR / 'cams_mcclear_1min_verbose.csv'

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
import pytest
33
import pvlib
44
import os
5-
from ..conftest import (TESTS_DATA_DIR, RERUNS, RERUNS_DELAY,
6-
requires_solaranywhere_credentials)
5+
from tests.conftest import (
6+
TESTS_DATA_DIR,
7+
RERUNS,
8+
RERUNS_DELAY,
9+
requires_solaranywhere_credentials,
10+
)
711

812
# High spatial resolution and 5-min data, true dynamics enabled
913
TESTFILE_HIGH_RESOLUTION = TESTS_DATA_DIR / 'Burlington, United States SolarAnywhere Time Series 20210101 to 20210103 Lat_44_4675 Lon_-73_2075 SA format.csv' # noqa: E501

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
import pytest
33
import pvlib
44
import requests
5-
from ..conftest import (RERUNS, RERUNS_DELAY, assert_frame_equal,
6-
assert_index_equal)
5+
from tests.conftest import (
6+
RERUNS,
7+
RERUNS_DELAY,
8+
assert_frame_equal,
9+
assert_index_equal,
10+
)
711

812

913
@pytest.fixture

0 commit comments

Comments
 (0)