Mention vscode tasks as alternative to shell commands ()

This commit is contained in:
dotvav 2024-12-09 23:25:28 +01:00 committed by GitHub
parent 865a38b623
commit 295afdefbc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 0 deletions

View File

@ -23,12 +23,16 @@ To run the full test suite, more dependencies are required than what is set up i
uv pip install -r requirements_test_all.txt
```
Or, in Visual Studio Code, launch the **Install all Test Requirements** task.
To start the tests, and run the full test suite, activate the virtual environment and run the command:
```shell
pytest tests
```
Or, in Visual Studio Code, launch the **Pytest** task.
It might be required that you install additional packages depending on your distribution/operating system:
- Fedora: `sudo dnf -y install systemd-devel gcc-c++`
@ -53,6 +57,9 @@ Next you can update all dependencies in your development environment by running:
```shell
uv pip install -r requirements_test_all.txt
```
Or, in Visual Studio Code, launch the **Install all Test Requirements** task.
### Running a limited test suite
You can pass arguments to `pytest` to be able to run single test suites or test files.
@ -79,6 +86,8 @@ the following command is recommended:
pytest ./tests/components/<your_component>/ --cov=homeassistant.components.<your_component> --cov-report term-missing -vv
```
Or, in Visual Studio Code, launch the **Code Coverage** task.
### Preventing linter errors
Several linters are setup to run automatically when you try to commit as part of running `script/setup` in the [virtual environment](development_environment.mdx).
@ -89,6 +98,8 @@ You can also run these linters manually :
pre-commit run --show-diff-on-failure
```
Or, in Visual Studio Code, launch the **Pre-commit** task.
The linters are also available directly, you can run tests on individual files:
```shell
@ -162,6 +173,8 @@ the `--snapshot-update` flag:
pytest tests/components/example/test_sensor.py --snapshot-update
```
Or, in Visual Studio Code, launch the **Update syrupy snapshots** task.
This will create a snapshot file in the `tests/components/example/snapshots`.
The snapshot file is named after the test file, in this case `test_sensor.ambr`,
and is human-readable. The snapshot files must be committed to the repository.