Skip to content

Commit c3a2666

Browse files
Use a dependency-group for testing (#1082)
* Use a dependency-group for testing * Add cython as test dependency * Fix distributed coverage * Split out coverage dependencies into separate group * Split test groups to enable full test run * itertools is part of Python stdlib --------- Co-authored-by: João Dionísio <57299939+Joao-Dionisio@users.noreply.github.com>
1 parent 0bbda09 commit c3a2666

File tree

12 files changed

+43
-30
lines changed

12 files changed

+43
-30
lines changed

.coveragerc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ omit =
55
tests
66
__init__.py
77
scip.pyx
8+
patch = subprocess

.github/workflows/build_wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
uses: pypa/cibuildwheel@v2.21.1
4545
env:
4646
CIBW_ARCHS: ${{ matrix.arch }}
47-
CIBW_TEST_REQUIRES: pytest
47+
CIBW_TEST_GROUPS: test
4848
CIBW_TEST_COMMAND: "pytest {project}/tests"
4949
CIBW_MANYLINUX_*_IMAGE: manylinux_2_28
5050

.github/workflows/coverage.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
- name: Prepare python environment
3737
run: |
3838
python -m pip install --upgrade pip
39-
python -m pip install networkx cython pytest-cov numpy
39+
python -m pip install --group coverage
4040
4141
- name: Install PySCIPOpt
4242
run: |
@@ -47,7 +47,8 @@ jobs:
4747
- name: Run pyscipopt tests
4848
run: |
4949
sudo apt-get install tzdata locales -y && sudo locale-gen pt_PT && sudo update-locale # add pt_PT locale that is used in tests
50-
coverage run -m pytest
50+
coverage run -m pytest -nauto
51+
coverage combine
5152
coverage report -m
5253
coverage xml
5354

.github/workflows/integration-test.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ jobs:
3434
- name: Prepare python environment
3535
run: |
3636
python -m pip install --upgrade pip
37-
python -m pip install networkx pytest-cov numpy
37+
python -m pip install --group test-full
3838
3939
- name: Install PySCIPOpt
4040
run: python -m pip install .
4141

4242
- name: Run pyscipopt tests
4343
run: |
44-
py.test
44+
py.test -nauto
4545
4646
Windows-test:
4747
env:
@@ -70,7 +70,7 @@ jobs:
7070
shell: powershell
7171
run: |
7272
python -m pip install --upgrade pip
73-
python -m pip install networkx pytest-cov numpy
73+
python -m pip install --group test-full
7474
7575
- name: Install PySCIPOpt
7676
shell: powershell
@@ -81,7 +81,7 @@ jobs:
8181
- name: Run pyscipopt tests
8282
shell: powershell
8383
run: |
84-
py.test
84+
py.test -nauto
8585
8686
MacOS-test:
8787
runs-on: macos-latest
@@ -107,7 +107,7 @@ jobs:
107107
- name: Prepare python environment
108108
run: |
109109
python -m pip install --upgrade pip
110-
python -m pip install networkx pytest-cov pytest numpy
110+
python -m pip install --group test-full
111111
112112
- name: Install PySCIPOpt
113113
run: |

.github/workflows/test-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: Prepare python environment
2929
run: |
3030
python -m pip install --upgrade pip
31-
python -m pip install wheel cython networkx pytest-cov build
31+
python -m pip install wheel cython build
3232
3333
- name: Build package
3434
run: |

.github/workflows/update-packages-and-documentation.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ jobs:
4949
- name: Prepare python environment
5050
run: |
5151
python -m pip install --upgrade pip
52-
python -m pip install wheel cython networkx pytest-cov
52+
python -m pip install --group test-full
5353
5454
- name: Install PySCIPOpt
5555
run: python -m pip install .
5656

5757
- name: Run pyscipopt tests
5858
run: |
59-
py.test
59+
py.test -nauto
6060
6161
windows-test:
6262
needs: release-integration-test
@@ -86,7 +86,7 @@ jobs:
8686
shell: powershell
8787
run: |
8888
python -m pip install --upgrade pip
89-
python -m pip install wheel cython networkx pytest-cov
89+
python -m pip install --group test-full
9090
- name: Install PySCIPOpt
9191
shell: powershell
9292
run: |
@@ -95,7 +95,7 @@ jobs:
9595
- name: Run pyscipopt tests
9696
shell: powershell
9797
run: |
98-
py.test
98+
py.test -nauto
9999
100100
101101
deploy-packages-and-generate-documentation:
@@ -117,7 +117,7 @@ jobs:
117117
- name: Prepare python environment
118118
run: |
119119
python -m pip install --upgrade pip
120-
python -m pip install wheel cython networkx pytest-cov build
120+
python -m pip install wheel cython build
121121
122122
- name: Build package
123123
run: |

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Implemented all binary operations between MatrixExpr and GenExpr
88
- Fixed the type of @ matrix operation result from MatrixVariable to MatrixExpr.
99
### Changed
10+
- Add a PEP 735 dependency group for test dependencies in `pyproject.toml`
1011
- Speed up MatrixVariable.sum(axis=None) via quicksum
1112
### Removed
1213

INSTALL.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,16 @@ Testing new installation
116116
========================
117117

118118
To test your brand-new installation of PySCIPOpt you need
119-
[pytest](https://pytest.org/) on your system.
119+
some dependencies which can be installed via pip. The testing
120+
dependencies are in the `test` dependency group.
120121

121-
pip install pytest
122-
123-
Here is the complete [installation
124-
procedure](https://docs.pytest.org/en/latest/getting-started.html).
122+
pip install --group test
125123

126124
Tests can be run in the `PySCIPOpt` directory with: :
127125

128126
py.test # all the available tests
129127
py.test tests/test_name.py # a specific tests/test_name.py (Unix)
128+
py.test -nauto # run tests in parallel using all available cores
130129

131130
Ideally, the status of your tests must be passed or skipped. Running
132131
tests with pytest creates the `__pycache__` directory in `tests` and,

docs/build.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,19 +177,21 @@ To use debug information in PySCIPOpt you need to build it with the following co
177177
Testing the Installation
178178
==========================
179179

180-
To test your brand-new installation of PySCIPOpt you need `pytest <https://docs.pytest.org/en/stable/>`_
181-
on your system. To get pytest simply run the command:
180+
To test your brand-new installation of PySCIPOpt you need to
181+
install some dependencies via pip. The testing dependencies are in
182+
the `test` dependency group.
182183

183184
.. code-block:: bash
184185
185-
pip install pytest
186+
pip install --group test
186187
187188
Tests can be run in the PySCIPOpt directory with the commands:
188189

189190
.. code-block:: bash
190191
191192
pytest # Will run all the available tests
192193
pytest tests/test_name.py # Will run a specific tests/test_name.py (Unix)
194+
pytest -nauto # Will run tests in parallel using all available cores
193195
194196
Ideally, the status of your tests must be passed or skipped.
195197
Running tests with pytest creates the __pycache__ directory in tests and, occasionally,

pyproject.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ dynamic = ["version"]
2626
[project.urls]
2727
Homepage = "https://github.com/SCIP-Interfaces/PySCIPOpt"
2828

29+
[dependency-groups]
30+
test = [
31+
"pytest",
32+
"pytest-xdist",
33+
]
34+
test-full = [
35+
{"include-group" = "test" },
36+
"networkx", # only needed for a few tests
37+
]
38+
coverage = [
39+
{ "include-group" = "test-full" },
40+
"coverage",
41+
"cython",
42+
]
43+
2944
[tool.pytest.ini_options]
3045
norecursedirs = ["check"]
3146
testpaths = ["tests"]

0 commit comments

Comments
 (0)