In this guide:
See first: Introduction to Vale rule development
Make sure that the rule has suitable test cases in tests/data/manifest.yml.
We recommend that you first install uv. To install uv on Ubuntu:
sudo snap install astral-uv --classic
To run the test cases for every rule:
-
If uv is installed
make -C tests run -
If uv is not installed
cd tests python3 -m venv .venv . .venv/bin/activate pip install -e . make run
Behind the scenes, we're using pytest to run each test case.
To run the test cases for a particular rule, such as 003-Ubuntu-names-versions:
-
If uv is installed
uv run --directory tests pytest -vv -k 003 -
If uv is not installed
# (Provided the working dir is 'tests' and the virtual environment is active) pytest -vv -k 003
The code in the tests directory uses Python with pytest. We require the code to be well-formatted and pass static checks.
Our tools of choice are:
If you've already installed ruff, you should be able to use it in the tests directory with no trouble. pyright is less straightforward, as it needs to be run in a virtual environment that contains the testing code's dependencies.
Instead of manually running these tools, we strongly recommend that you install uv and use make in the tests directory.
| Command | Purpose |
|---|---|
make format |
Use ruff to format the testing code |
make lint |
Use ruff to check code conventions and pyright to check types |
make run |
Use pytest to run the test cases for every rule |