Skip to content
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
17 changes: 15 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,23 @@ jobs:
with:
python-version: "${{ matrix.python-version }}"

- name: "Install dependencies in pyproject.toml"
- name: "Install test and project dependencies"
run: |
# Project dependencies from pyproject.toml
# NOTE: Also builds viscm. How do we avoid this?
pip install .
pip install pytest pytest-cov ${{ matrix.pyqt-dependency }}

# Test dependencies
pip install pytest pytest-cov pytest-qt pytest-xvfb ${{ matrix.pyqt-dependency }}
# pytest-qt CI dependencies: https://pytest-qt.readthedocs.io/en/latest/troubleshooting.html#github-actions
sudo apt update
sudo apt install -y \
xvfb \
libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 x11-utils

- name: "Run tests"
run: "make test"
env:
# In Pythons >= 3.10, tests fail with `RuntimeError: Invalid DISPLAY
# variable`, unless this variable is set:
MPLBACKEND: "Agg"
31 changes: 27 additions & 4 deletions doc/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,37 @@

Install development dependencies:

```
```bash
conda env create # or `mamba env create`
```


## Development install

```
```bash
pip install -e .
```


## Testing the build

```
```bash
rm -rf dist
python -m build
pip install dist/*.whl # or `dist/*.tar.gz`
```


## Code formatting and linting
## Tests

See `Makefile` for convenience commands.


### Code linting (and formatting)

```bash
make lint
```

This codebase uses [black](https://black.readthedocs.io/en/stable/) and
[ruff](https://github.com/charliermarsh/ruff) to automatically format and lint the code.
Expand All @@ -37,3 +46,17 @@ and then another commit should immediately follow which updates
`.git-blame-ignore-revs`. For example:
[1fec42d](https://github.com/matplotlib/viscm/pull/64/commits/1fec42d0baf90e00d510efd76cb6006fa0c70dc4),
[8aa7bb0](https://github.com/matplotlib/viscm/pull/64/commits/8aa7bb01440aeca6f8bbcefe0671c28f2ce284c6).


### Unit tests

```bash
make test
```

Unit tests require `xvfb` (X Virtual Framebuffer) to test the GUI. If `xvfb` is not

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we skip the tests instead with a warning? That's what we do on most other projects with the pytest.importorskip decorator (reads: import or skip)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this will help, or I'm not quite understanding the suggestion :) xvfb isn't something we can import, it's a system dependency that needs to be present. I'll look in to other ways we might make this test conditional!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took some tinkering, but I figured out a good way to skip those tests: b86bf1a

installed, GUI tests will be skipped. Install with:

```bash
sudo apt install xvfb
```
10 changes: 10 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from pathlib import Path

import pytest


@pytest.fixture
def tests_data_dir() -> Path:
tests_dir = Path(__file__).parent.resolve()
tests_data_dir = tests_dir / "data"
return tests_data_dir
Loading