Skip to content

Commit c2f31b9

Browse files
authored
Merge pull request #24 from openscm/add-extra-test
Add extra test
2 parents e28bb2f + b2a7598 commit c2f31b9

File tree

9 files changed

+102
-19
lines changed

9 files changed

+102
-19
lines changed

.github/workflows/ci.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,42 @@ jobs:
104104
env:
105105
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
106106

107+
tests-without-extras:
108+
# Run the tests without installing extras.
109+
# This is just a test to make sure to avoid
110+
# breaking our test PyPI install workflow.
111+
strategy:
112+
fail-fast: false
113+
matrix:
114+
os: [ "ubuntu-latest" ]
115+
# Just test against one Python version, this is just a helper.
116+
# The real work happens in the test PyPI install
117+
python-version: [ "3.11" ]
118+
runs-on: "${{ matrix.os }}"
119+
defaults:
120+
run:
121+
# This might be needed for Windows
122+
# and doesn't seem to affect unix-based systems so we include it.
123+
# If you have better proof of whether this is needed or not,
124+
# feel free to update.
125+
shell: bash
126+
steps:
127+
- name: Check out repository
128+
uses: actions/checkout@v4
129+
- name: Set up Python "${{ matrix.python-version }}"
130+
id: setup-python
131+
uses: actions/setup-python@v4
132+
with:
133+
python-version: "${{ matrix.python-version }}"
134+
- name: Install
135+
run: |
136+
pip install --upgrade pip wheel
137+
pip install .
138+
pip install -r requirements-only-tests-locked.txt
139+
- name: Run tests
140+
run: |
141+
pytest tests -r a -vv tests
142+
107143
imports-without-extras:
108144
strategy:
109145
fail-fast: false

.github/workflows/install-pypi.yaml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,10 @@ jobs:
7575
# So this is really just a smoke test,
7676
# rather than a super thorough integration test.
7777
pytest tests -r a -vv tests
78-
# # This is a sketch of how you would do more thorough tests.
79-
# # I don't like this solution because it is out of line with the lock file.
80-
# # Probably the simplest way to do this is to use uv somehow,
81-
# # install the package from pypi and the test dependencies
82-
# # based on the lock file.
83-
# - name: Install extra test dependencies
84-
# run: |
85-
# # A bit annoying to maintain this by hand, but ok for now.
86-
# pip install ipython matplotlib openscm-units scipy
87-
# - name: Run tests with extra test dependencies installed
88-
# run: |
89-
# # Can't run doctests here because the paths are different.
90-
# pytest tests -r a -vv tests
78+
- name: Install all test dependencies
79+
run: |
80+
pip install -r requirements-only-tests-locked.txt
81+
- name: Run tests with extra test dependencies installed
82+
run: |
83+
# Can't run doctests here because the paths are different.
84+
pytest tests -r a -vv tests

.pre-commit-config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ repos:
5555
- id: uv-export
5656
name: export-requirements-docs
5757
args: ["-o", "requirements-docs-locked.txt", "--no-hashes", "--no-dev", "--no-emit-project", "--all-extras", "--group", "docs"]
58+
- id: uv-export
59+
name: export-requirements-only-tests
60+
args: ["-o", "requirements-only-tests-locked.txt", "--no-hashes", "--no-dev", "--no-emit-project", "--only-group", "tests"]
5861
# # Not released yet
5962
# - id: uv-sync
6063
- repo: https://github.com/pdm-project/pdm

changelog/24.trivial.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added a test to the CI to try and avoid breaking the PyPI install test inadvertently again.

requirements-only-tests-locked.txt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# This file was autogenerated by uv via the following command:
2+
# uv export -o requirements-only-tests-locked.txt --no-hashes --no-dev --no-emit-project --only-group tests
3+
asttokens==3.0.0
4+
colorama==0.4.6 ; sys_platform == 'win32'
5+
coverage==7.6.10
6+
decorator==5.1.1
7+
exceptiongroup==1.2.2 ; python_full_version < '3.11'
8+
executing==2.1.0
9+
flexcache==0.3
10+
flexparser==0.4
11+
globalwarmingpotentials==0.11.1
12+
iniconfig==2.0.0
13+
ipython==8.18.1
14+
jedi==0.19.2
15+
matplotlib-inline==0.1.7
16+
numpy==2.0.2 ; python_full_version < '3.10'
17+
numpy==2.2.0 ; python_full_version >= '3.10'
18+
openscm-units==0.6.3
19+
packaging==24.2
20+
pandas==2.2.3
21+
parso==0.8.4
22+
pexpect==4.9.0 ; sys_platform != 'win32'
23+
pint==0.24.4
24+
platformdirs==4.3.6
25+
pluggy==1.5.0
26+
prompt-toolkit==3.0.48
27+
ptyprocess==0.7.0 ; sys_platform != 'win32'
28+
pure-eval==0.2.3
29+
pygments==2.19.1
30+
pytest==8.3.4
31+
pytest-cov==6.0.0
32+
pytest-datadir==1.5.0
33+
pytest-regressions==2.6.0
34+
python-dateutil==2.9.0.post0
35+
pytz==2024.2
36+
pyyaml==6.0.2
37+
scipy==1.13.1 ; python_full_version < '3.10'
38+
scipy==1.14.1 ; python_full_version >= '3.10'
39+
six==1.17.0
40+
stack-data==0.6.3
41+
tomli==2.2.1 ; python_full_version <= '3.11'
42+
traitlets==5.14.3
43+
typing-extensions==4.12.2
44+
tzdata==2024.2
45+
wcwidth==0.2.13

tests/integration/test_timeseries_continous_integration.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ def test_differentiate(operations_test_case, differentiate_kwargs):
673673
def test_plot( # noqa: PLR0913
674674
x_units, y_units, plot_kwargs, legend, time_axis_plot, image_regression, tmp_path
675675
):
676-
import matplotlib
676+
matplotlib = pytest.importorskip("matplotlib")
677677

678678
# ensure matplotlib does not use a GUI backend (such as Tk)
679679
matplotlib.use("Agg")
@@ -782,7 +782,7 @@ def test_plot( # noqa: PLR0913
782782
def test_plot_matplotlib_units_not_registered(
783783
plot_kwargs, expectation, image_regression, tmp_path
784784
):
785-
import matplotlib
785+
matplotlib = pytest.importorskip("matplotlib")
786786

787787
# ensure matplotlib does not use a GUI backend (such as Tk)
788788
matplotlib.use("Agg")
@@ -828,6 +828,8 @@ def test_plot_matplotlib_units_not_registered(
828828
),
829829
)
830830
def test_plot_ax_creation(sys_modules_patch, expectation):
831+
pytest.importorskip("matplotlib")
832+
831833
ts = TimeseriesContinuous(
832834
name="piecewise_quadratic",
833835
time_units=UR.Unit("yr"),

tests/integration/test_timeseries_discrete_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def test_plot_matplotlib_units_not_registered(
316316
),
317317
)
318318
def test_plot_ax_creation(sys_modules_patch, expectation):
319-
(pytest.importorskip("matplotlib"),)
319+
pytest.importorskip("matplotlib")
320320

321321
ts = TimeseriesDiscrete(
322322
name="basic",

tests/integration/test_timeseries_integration.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,7 @@ def test_differentiate_then_integrate(start_interp, exp_result):
12211221
def test_plot( # noqa: PLR0913
12221222
x_units, y_units, plot_kwargs, legend, image_regression, tmp_path
12231223
):
1224-
import matplotlib
1224+
matplotlib = pytest.importorskip("matplotlib")
12251225

12261226
# ensure matplotlib does not use a GUI backend (such as Tk)
12271227
matplotlib.use("Agg")
@@ -1322,7 +1322,7 @@ def test_plot( # noqa: PLR0913
13221322
def test_plot_matplotlib_units_not_registered(
13231323
plot_kwargs, expectation, image_regression, tmp_path
13241324
):
1325-
import matplotlib
1325+
matplotlib = pytest.importorskip("matplotlib")
13261326

13271327
# ensure matplotlib does not use a GUI backend (such as Tk)
13281328
matplotlib.use("Agg")
@@ -1364,6 +1364,8 @@ def test_plot_matplotlib_units_not_registered(
13641364
),
13651365
)
13661366
def test_plot_ax_creation(sys_modules_patch, expectation):
1367+
pytest.importorskip("matplotlib")
1368+
13671369
ts = Timeseries.from_arrays(
13681370
x=Q([1.0, 10.0, 20.0], "yr"),
13691371
y=Q([10.0, 12.0, 32.0], "Mt / yr"),

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)