You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/add-ons/configuration.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -82,7 +82,7 @@ LABEL \
82
82
io.hass.arch="armhf|aarch64|i386|amd64"
83
83
```
84
84
85
-
It is possible to use your own base image with `build.yaml` or if you do not need support for automatic multi-arch building you can also use a simple docker `FROM`.
85
+
It is possible to use your own base image with `build.yaml` or if you do not need support for automatic multi-arch building you can also use a simple docker `FROM`. You can also suffix the Dockerfile with the specific architecture to use a specific Dockerfile for a particular architecture, i.e. `Dockerfile.amd64`.
Copy file name to clipboardExpand all lines: docs/config_entries_config_flow_handler.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -322,4 +322,4 @@ Automated tests should verify that the reauth flow updates the existing config e
322
322
323
323
## Testing your config flow
324
324
325
-
Integrations with a config flow require full test coverage of all code in `config_flow.py` to be accepted into core. [Test your code](development_testing.md#testing-outside-of-tox) includes more details on how to generate a coverage report.
325
+
Integrations with a config flow require full test coverage of all code in `config_flow.py` to be accepted into core. [Test your code](development_testing.md#running-a-limited-test-suite) includes more details on how to generate a coverage report.
Copy file name to clipboardExpand all lines: docs/development_testing.md
+40-40Lines changed: 40 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,10 +7,18 @@ As it states in the [Style guidelines section](development_guidelines.md) all co
7
7
- All the unit tests pass
8
8
- All code passes the checks from the linting tools
9
9
10
-
Local testing is done using [Tox](https://tox.readthedocs.io), which has been installed as part of running `script/setup` in the [virtual environment](development_environment.mdx). To start the tests, activate the virtual environment and simply run the command:
10
+
Local testing is done using [pytest](https://docs.pytest.org/) and using [pre-commit](https://pre-commit.com/) for running out linters, which has been installed as part of running `script/setup` in the [virtual environment](development_environment.mdx).
11
+
12
+
To run our linters, on the full code base, run the following command:
13
+
14
+
```shell
15
+
pre-commit run --all-files
16
+
```
17
+
18
+
To start the tests, and run the full test suite, activate the virtual environment and run the command:
11
19
12
20
```shell
13
-
tox
21
+
pytest tests
14
22
```
15
23
16
24
It might be required that you install additional packages depending on your distribution/operating system:
@@ -19,62 +27,45 @@ It might be required that you install additional packages depending on your dist
19
27
- Ubuntu: `sudo apt-get install libudev-dev`
20
28
21
29
:::info Important
22
-
Run `tox` before you create your pull request to avoid annoying fixes.
30
+
Run `pytest` & `pre-commit` before you create your pull request to avoid annoying fixes.
31
+
`pre-commit` will will be invoked automatically by git when commiting changes.
23
32
:::
24
33
25
34
:::note
26
-
Running the full `tox` test suite will take quite some time, so as the minimal requirement for pull requests, run at least the tests that are related to your code changes (see details below on how to). The full test suite will anyway be run by the CI once you created your pull request and before it can be merged.
35
+
Running the full `ptyest` test suite will take quite some time, so as the minimal requirement for pull requests, run at least the tests that are related to your code changes (see details below on how to). The full test suite will anyway be run by the CI once you created your pull request and before it can be merged.
27
36
:::
28
37
29
-
Running `tox` will run unit tests against the locally available Python releases, as well as validate the code and document style using `pycodestyle`, `pydocstyle` and `pylint`. You can run tests on only one `tox` target -- just use `-e` to select an environment. For example, `tox -e lint` runs the linters only, and `tox -e py39` runs unit tests only on Python 3.9.
30
-
31
-
`tox` uses virtual environments under the hood to create isolated testing environments. The `tox` virtual environments will get out-of-date when requirements change, causing test errors. Run `tox -r` to tell `tox` to recreate the virtual environments.
32
-
33
-
macOS users may see an `Error creating virtualenv` when running `tox`. If this occurs, install the [tox-venv](https://pypi.org/project/tox-venv/) package using the command `pip install tox-venv` and try again.
38
+
Running `pytest` will run unit tests against the locally available Python version. We run our tests in our CI against all our supported Python versions.
34
39
35
40
### Adding new dependencies to test environment
36
41
37
-
If you are working on tests for an integration and you need the dependencies available inside the `tox` environment, update the list inside `script/gen_requirements_all.py`. Then run the script and then run `tox -r` to recreate the virtual environments.
38
-
39
-
### Running single tests using `tox`
40
-
41
-
You can pass arguments via `tox` to `pytest` to be able to run single test suites or test files. Replace `py39` with the Python version that you use.
Running `tox` will invoke the full test suite. Even if you specify which tox target to run, you still run all tests inside that target. That's not very convenient to quickly iterate on your code! To be able to run the specific test suites without `tox`, you'll need to install the test dependencies into your Python environment:
42
+
If you are working on tests for an integration and you changed the dependencies, then run the `script/gen_requirements_all.py` script to update all requirement files.
43
+
Next you can update all dependencies in your development environment by running:
Now that you have all test dependencies installed, you can run tests on individual files:
50
+
You can pass arguments to `pytest` to be able to run single test suites or test files.
51
+
Here are some helpful commands:
63
52
64
53
```shell
65
-
flake8 homeassistant/core.py
66
-
pylint homeassistant/core.py
67
-
pydocstyle homeassistant/core.py
68
-
pytest tests/test_core.py
69
-
```
54
+
# Stop after the first test fails
55
+
$ pytest tests/test_core.py -x
70
56
71
-
You can also run linting tests against all changed files, as reported by `git diff upstream/dev... --diff-filter=d --name-only`, using the `lint` script:
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).
86
77
87
-
You can also run these linters manually:
78
+
You can also run these linters manually:
88
79
89
80
```shell
90
81
pre-commit run --show-diff-on-failure
91
82
```
92
83
84
+
The linters are also available directly, you can run tests on individual files:
85
+
86
+
```shell
87
+
flake8 homeassistant/core.py
88
+
pylint homeassistant/core.py
89
+
black homeassistant/core.py
90
+
isort homeassistant/core.py
91
+
```
92
+
93
93
### Notes on PyLint and PEP8 validation
94
94
95
95
If you can't avoid a PyLint warning, add a comment to disable the PyLint check for that line with `# pylint: disable=YOUR-ERROR-NAME`. Example of an unavoidable one is if PyLint incorrectly reports that a certain object doesn't have a certain member.
0 commit comments