Skip to content

Latest commit

 

History

History
79 lines (52 loc) · 2.62 KB

File metadata and controls

79 lines (52 loc) · 2.62 KB

In this guide:

Guidance for maintainers of the rules

See first: Introduction to Vale rule development

Add test cases for a rule

Make sure that the rule has suitable test cases in tests/data/manifest.yml.

Run all test cases

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
    

Run selected test cases

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
    

Guidance for maintainers of the testing code

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:

  • ruff for formatting and checking code conventions
  • pyright for checking types

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