developer guide enhancements.

This commit is contained in:
Ketan Patel 2019-05-08 00:40:40 -07:00
parent ae2b8f0056
commit 900020ddc9

View File

@ -34,16 +34,72 @@ the document that explains the way `sanic` manages dependencies inside the `setu
| extras_require['dev'] | Additional Development requirements to add contributing | pip3 install -e '.[dev]' |
| extras_require['docs'] | Dependencies required to enable building and enhancing sanic documentation | pip3 install -e '.[docs]' |
## Running tests
To run the tests for sanic it is recommended to use tox like so:
## Running all tests
To run the tests for Sanic it is recommended to use tox like so:
```bash
tox
```
See it's that simple!
`tox.ini` contains different environments. Running `tox` without any arguments will
run all unittests, perform lint and other checks.
## Run unittests :
`tox` environment -> `[testenv]`
To execute only unittests, run `tox` with environment like so:
```bash
tox -e py36 -v -- tests/test_config.py
# or
tox -e py37 -v -- tests/test_config.py
```
## Run lint checks :
`tox` environment -> `[testenv:lint]`
Permform `flake8`, `black` and `isort` checks.
```bash
tox -e lint
```
## Run other checks :
`tox` environment -> `[testenv:check]`
Perform other checks.
```bash
tox -e check
```
# Code Style
To maintain the code consistency, Sanic uses following tools.
1. [isort](https://github.com/timothycrosley/isort)
2. [black](https://github.com/python/black)
2. [flake8](https://github.com/PyCQA/flake8)
## isort
`isort` sorts Python imports. It divides imports into three
categories sorted each in alphabetical order.
1. built-in
2. third-party
3. project-specific
## black
`black` is a Python code formatter.
## flake8
`flake8` is a Python style guide that wraps following tools into one.
1. PyFlakes
2. pycodestyle
3. Ned Batchelder's McCabe script
`isort`, `black` and `flake8` checks are performed during `tox` lint checks.
Refer [tox](https://tox.readthedocs.io/en/latest/index.html) documentation for more details.
## Pull requests!
So the pull request approval rules are pretty simple: