Skip to content

Commit cf3380a

Browse files
committed
Rejig tox test running to remove tox-conda
tox-conda doesn't work with tox 4, and is becoming so out of date that recent versions of Python and other dependencies start failing. I couldn't get a working combination of dependencies on Python 3.12.
1 parent 3df0ee9 commit cf3380a

File tree

2 files changed

+39
-37
lines changed

2 files changed

+39
-37
lines changed

docs/testing.rst

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,48 @@ Python tests use the `pytest`_ framework,
88
`flake8`_ and `isort`_ check the code formatting,
99
and the documentation is build using `sphinx`_
1010

11-
Setup
12-
=====
11+
Using tox
12+
=========
1313

14-
To install all the testing tools,
15-
install ``emsarray`` in to a virtual environment with the ``[testing]`` extra.
14+
The easiest way to install all the test requirements is using Conda:
1615

17-
.. code-block:: shell-session
16+
* Make a new Conda environment,
17+
* install the required packages using the provided environment file,
18+
* install Python and tox.
1819

19-
$ python3 -m venv venv
20-
$ source venv/bin/activate
21-
$ pip3 install --upgrade pip
22-
$ pip3 install -r requirements.txt -e .[testing]
20+
.. code-block:: shell-session
2321
24-
Running all the tests
25-
=====================
22+
$ conda env create --name 'emsarray-tests-py3.12' --file continuous-integration/environment.yaml
23+
$ conda activate emsarray-tests-py3.12
24+
$ conda install -c conda-forge python==3.12 tox
2625
2726
Invoke ``tox`` to run all the tests:
2827

2928
.. code-block:: shell-session
3029
31-
$ tox
30+
$ tox run -e py312-pytest-latest py312-pytest-pinned lint docs
3231
33-
Running Python tests
34-
====================
32+
Note that this should only be used to run tests for the version of Python you
33+
installed in your Conda environment.
34+
35+
Using pytest
36+
============
3537

3638
You can invoke ``pytest`` directly to run just a subset of the tests.
37-
For example, to only run the tests in ``tests/operations.py``:
39+
Set up a new Conda environment, then install `emsarray` with the `testing` extra:
40+
41+
.. code-block:: shell-session
42+
43+
$ conda env create --name 'emsarray-development' --file continuous-integration/environment.yaml
44+
$ conda activate emsarray-development
45+
$ conda install -c conda-forge python=3.12 pip
46+
$ pip install -e .[testing]
47+
48+
Invoke ``pytest`` to run the tests:
3849

3950
.. code-block:: shell-session
4051
41-
$ pytest tests/test_operations.py
52+
$ pytest
4253
4354
.. _tox: https://tox.wiki/
4455
.. _pytest: https://pytest.org/

tox.ini

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,26 @@ isolated_build = true
33
package = wheel
44
wheel_build_env = .pkg
55
envlist =
6-
py{310,311,312}-pytest-locked
6+
py{310,311,312}-pytest-pinned
7+
py310-pytest-minimum
78
py312-pytest-latest
89
lint,docs
910
skip_missing_interpreters = true
10-
requires =
11-
tox-conda
1211

1312
[testenv]
1413
setenv =
1514
# Conda doesn't isolate its environment from ~/.local,
1615
# which can lead to strange conflicts
1716
PYTHONNOUSERSITE = 1
1817
sitepackages = false
18+
passenv =
19+
UDUNITS2_XML_PATH
1920

20-
# Install some binary packages through conda
21-
conda_channels = conda-forge
22-
conda_install_args = --override-channels
23-
conda_deps =
24-
pip
25-
wheel
26-
geos ~= 3.10.2
27-
udunits2 >=2.2.25
28-
29-
# Install the python dependencies through pip
30-
deps = -rcontinuous-integration/requirements.txt
31-
32-
[testenv:py{39,310,311}-pytest-{locked,latest}]
21+
[testenv:py{310,311,312}-pytest-{pinned,latest,minimum}]
22+
description = "Run the pytest test suite against a specific Python version and dependencies"
3323
deps =
34-
locked: -rcontinuous-integration/requirements.txt
24+
pinned: -rcontinuous-integration/requirements.txt
25+
minimum: -rcontinuous-integration/requirements-minimum.txt
3526
extras =
3627
latest: testing
3728
commands =
@@ -44,15 +35,15 @@ setenv =
4435
EMSARRAY_DATA_DIR = {envtmpdir}/emsarray_tutorial
4536

4637
[testenv:lint]
47-
basepython = python3.12
48-
skip_install = true
38+
description = "Run the lint checkers"
39+
extras = testing
4940
commands =
5041
isort --diff --check-only src/ tests/
5142
flake8 src/ tests/
5243
mypy --junit-xml report-mypy.xml src/
5344

5445
[testenv:docs]
55-
basepython = python3.12
56-
skip_install = true
46+
description = "Build the docs"
47+
extras = complete,docs
5748
changedir = docs/
5849
commands = sphinx-build -b html -aEW . _build/html

0 commit comments

Comments
 (0)