Skip to content

Commit e717e0a

Browse files
authored
Merge branch 'master' into patch-1
2 parents d097f2f + 086a5ab commit e717e0a

File tree

7 files changed

+45
-46
lines changed

7 files changed

+45
-46
lines changed

docs/add-ons/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ LABEL \
8282
io.hass.arch="armhf|aarch64|i386|amd64"
8383
```
8484

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`.
8686

8787
### Build Args
8888

docs/config_entries_config_flow_handler.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,4 +322,4 @@ Automated tests should verify that the reauth flow updates the existing config e
322322

323323
## Testing your config flow
324324

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.

docs/development_testing.md

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,18 @@ As it states in the [Style guidelines section](development_guidelines.md) all co
77
- All the unit tests pass
88
- All code passes the checks from the linting tools
99

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:
1119

1220
```shell
13-
tox
21+
pytest tests
1422
```
1523

1624
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
1927
- Ubuntu: `sudo apt-get install libudev-dev`
2028

2129
:::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.
2332
:::
2433

2534
:::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.
2736
:::
2837

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.
3439

3540
### Adding new dependencies to test environment
3641

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.
42-
43-
```shell
44-
# Stop after the first test fails
45-
$ tox -e py39 -- tests/test_core.py -x
46-
# Run test with specified name
47-
$ tox -e py39 -- tests/test_core.py -k test_split_entity_id
48-
# Fail a test after it runs for 2 seconds
49-
$ tox -e py39 -- tests/test_core.py --timeout 2
50-
# Show the 10 slowest tests
51-
$ tox -e py39 -- tests/test_core.py --duration=10
52-
```
53-
54-
### Testing outside of Tox
55-
56-
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:
5744

5845
```shell
5946
pip3 install --use-deprecated=legacy-resolver -r requirements_test_all.txt -c homeassistant/package_constraints.txt
6047
```
48+
### Running a limited test suite
6149

62-
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:
6352

6453
```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
7056

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:
57+
# Run test with specified name
58+
$ pytest tests/test_core.py -k test_split_entity_id
7259

73-
```shell
74-
script/lint
60+
# Fail a test after it runs for 2 seconds
61+
$ pytest tests/test_core.py --timeout 2
62+
63+
# Show the 10 slowest tests
64+
$ pytest tests/test_core.py --duration=10
7565
```
7666

77-
In case you want to check the code coverage for your new component, run the following from the root of the repository:
67+
If you want to test just your integration, and include a test coverage report,
68+
the following command is recommended:
7869

7970
```shell
8071
pytest ./tests/components/<your_component>/ --cov=homeassistant.components.<your_component> --cov-report term-missing -vv
@@ -84,12 +75,21 @@ pytest ./tests/components/<your_component>/ --cov=homeassistant.components.<your
8475

8576
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).
8677

87-
You can also run these linters manually:
78+
You can also run these linters manually :
8879

8980
```shell
9081
pre-commit run --show-diff-on-failure
9182
```
9283

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+
9393
### Notes on PyLint and PEP8 validation
9494

9595
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.

docs/documenting/yaml-style-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ In the examples above the no chomping operators are used (`|`, `>`). This is
202202
preferred, unless the example requires a different handling of the ending new
203203
line. In those cases the use of the strip operator (`|-`, `>-`: no trailing new
204204
line, any additional new lines are removed from the end) or keep operator
205-
(`|+`, `|-`: trailing new line, and keep all additional new lines from the end)
205+
(`|+`, `>+`: trailing new line, and keep all additional new lines from the end)
206206
is allowed.
207207

208208
### Additional string guidance

docusaurus.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ module.exports = {
142142
],
143143
},
144144
],
145-
copyright: `Copyright © ${new Date().getFullYear()} Home Assistant, Inc. Built with Docusaurus.`,
145+
copyright: `Copyright © ${new Date().getFullYear()} Home Assistant. Built with Docusaurus.`,
146146
},
147147
image: "img/default-social.png",
148148
},

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"@docusaurus/core": "^2.2.0",
1616
"@docusaurus/preset-classic": "^2.2.0",
1717
"@easyops-cn/docusaurus-search-local": "^0.33.5",
18-
"@mdx-js/react": "^1.6.21",
1918
"by-node-env": "^2.0.1",
2019
"clsx": "^1.2.1",
2120
"react": "^18.2.0",

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1731,7 +1731,7 @@
17311731
unist-builder "2.0.3"
17321732
unist-util-visit "2.0.3"
17331733

1734-
"@mdx-js/react@^1.6.21", "@mdx-js/react@^1.6.22":
1734+
"@mdx-js/react@^1.6.22":
17351735
version "1.6.22"
17361736
resolved "https://registry.yarnpkg.com/@mdx-js/react/-/react-1.6.22.tgz#ae09b4744fddc74714ee9f9d6f17a66e77c43573"
17371737
integrity sha512-TDoPum4SHdfPiGSAaRBw7ECyI8VaHpK8GJugbJIJuqyh6kzw9ZLJZW3HGL3NNrJGxcAixUvqROm+YuQOo5eXtg==

0 commit comments

Comments
 (0)