Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce tox for testing #197

Merged
merged 21 commits into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ name: Build and Test
on:
push:
branches:
- master
- develop
- '*'
pull_request:
paths:
- '**'
- '*'

jobs:
sdist:
Expand All @@ -28,21 +27,18 @@ jobs:
test:
name: Run mock unit tests
runs-on: ubuntu-latest
container: precice/precice:nightly
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Install FEniCS and scipy (see https://github.com/precice/fenics-adapter/issues/189)
- name: Install FEniCS and tox
run: |
sudo add-apt-repository ppa:fenics-packages/fenics
sudo apt-get update
sudo apt-get install -y python3-scipy fenics
- name: Install fake precice
run: |
mkdir -p precice
echo "from setuptools import setup" >> precice/setup.py
echo "setup(name='pyprecice', version='3.0.0.0')" >> precice/setup.py
pip3 install --break-system-packages ./precice/
apt update
apt install -y software-properties-common
add-apt-repository ppa:fenics-packages/fenics -y
apt update
apt install -y fenics tox
- name: Run unit tests
run: python3 setup.py test -s tests.unit
run: tox -e unit
- name: Run integration tests
run: python3 setup.py test -s tests.integration
run: tox -e integration
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ After cloning this repository and switching to the root directory (`fenics-adapt

As a first test, try to import the adapter via `python3 -c "import fenicsprecice"`.

You can run the other tests via `python3 setup.py test`.
You can run the other tests via `tox`.
If you want to run them separately, use `tox -e unit` and `tox -e integration` respectively.

Single tests can be also be run. For example the test `test_vector_write` in the file `test_write_read.py` can be run as follows:

```bash
python3 -m unittest tests.test_write_read.TestWriteandReadData.test_vector_write
tox -e all -- tests/integration/test_write_read.py::TestWriteandReadData::test_vector_write
```

#### Troubleshooting
Expand Down
30 changes: 30 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[tox]
requires =
tox>=4
env_list = all

[testenv]
skip_install = True
description = base environment for testing
deps =
pytest>=8
numpy>=1.13.3,<2
scipy<1.15.0
mpi4py<4
sitepackages = True

[testenv:all]
description = run all tests
commands =
pytest {posargs}

[testenv:unit]
description = run unit tests
commands =
pytest tests/unit

[testenv:integration]
description = run integration tests
commands =
pytest tests/integration

Loading