mirror of
https://github.com/home-assistant/developers.home-assistant.git
synced 2025-11-15 22:10:14 +00:00
Fix all headers
This commit is contained in:
@@ -1,12 +1,6 @@
|
||||
---
|
||||
layout: page
|
||||
title: "Testing your code"
|
||||
description: "Make sure that your code passes the checks"
|
||||
date: 2016-07-01 20:00
|
||||
sidebar: true
|
||||
comments: false
|
||||
sharing: true
|
||||
footer: true
|
||||
---
|
||||
|
||||
As states in the [Style guidelines section](/developers/development_guidelines/) all code is checked to verify all unit tests pass and that the code passes the linting tools. Local testing is done using Tox, which has been installed as part of running `script/setup`. To start the tests, simply run it:
|
||||
@@ -22,7 +16,7 @@ Tox uses virtual environments under the hood to create isolated testing environm
|
||||
|
||||
If you are working on tests for a component or platform 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.
|
||||
|
||||
### {% linkable_title Running single tests using Tox %}
|
||||
### Running single tests using Tox
|
||||
|
||||
You can pass arguments via Tox to py.test to be able to run single test suites or test files. Replace `py36` with the Python version that you use.
|
||||
|
||||
@@ -37,7 +31,7 @@ $ tox -e py36 -- tests/test_core.py --timeout 2
|
||||
$ tox -e py36 -- tests/test_core.py --duration=10
|
||||
```
|
||||
|
||||
### {% linkable_title Testing outside of Tox %}
|
||||
### Testing outside of Tox
|
||||
|
||||
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:
|
||||
|
||||
@@ -60,7 +54,7 @@ You can also run linting tests against all changed files, as reported by `git di
|
||||
$ script/lint
|
||||
```
|
||||
|
||||
### {% linkable_title Preventing Linter Errors %}
|
||||
### Preventing Linter Errors
|
||||
|
||||
Save yourself the hassle of extra commits just to fix style errors by enabling the Flake8 git commit hook. Flake8 will check your code when you try to commit to the repository and block the commit if there are any style errors, which gives you a chance to fix them!
|
||||
|
||||
@@ -71,6 +65,6 @@ $ flake8 --install-hook=git
|
||||
|
||||
The `flake8-docstrings` extension will check docstrings according to [PEP257](https://www.python.org/dev/peps/pep-0257/) when running Flake8.
|
||||
|
||||
### {% linkable_title Notes on PyLint and PEP8 validation %}
|
||||
### Notes on PyLint and PEP8 validation
|
||||
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user