|
1 | | -# Pyscript tests |
| 1 | +# Pyscript Development Setup |
2 | 2 |
|
3 | | -For running the tests, you should setup a python virtualenv in the project root directory: |
| 3 | +These setup commands only need to be executed once. First, clone the repository: |
4 | 4 | ```bash |
5 | | -python3 -m venv venv |
| 5 | +git clone https://github.com/custom-components/pyscript.git |
| 6 | +cd pyscript |
| 7 | +``` |
| 8 | + |
| 9 | +Next, create a virtual environment (make sure `python` is version `3.x`; otherwise use `python3`): |
| 10 | +```bash |
| 11 | +python -m venv venv |
6 | 12 | source venv/bin/activate |
7 | 13 | ``` |
8 | 14 |
|
9 | | -Install needed dependencies: |
| 15 | +Finally, install the requirements and the pre-commit hooks: |
10 | 16 | ```bash |
11 | | -python3 -m pip install -r requirements_test.txt |
| 17 | +python -m pip install -r requirements_test.txt |
| 18 | +pre-commit install |
| 19 | +``` |
| 20 | + |
| 21 | +To develop code and submit PRs you will want to fork the repository, and follow the |
| 22 | +steps above on your forked repository. Once you have pushed your changes to the fork, |
| 23 | +you can go ahead and submit a PR. |
| 24 | + |
| 25 | +# Pyscript Tests |
| 26 | + |
| 27 | +This directory contains various tests for pyscript. |
| 28 | + |
| 29 | +After completing the above setup steps, you need to activate the virtual environment |
| 30 | +every time you start a new shell: |
| 31 | +```bash |
| 32 | +source venv/bin/activate |
12 | 33 | ``` |
13 | 34 |
|
14 | 35 | Now you can run the tests using this command: |
15 | 36 | ```bash |
16 | 37 | pytest |
17 | 38 | ``` |
18 | | - |
19 | | -Always remember to activate the virtualenv before running anything: |
| 39 | +or run a specific test file with: |
20 | 40 | ```bash |
21 | | -source venv/bin/activate |
| 41 | +pytest tests/test_function.py |
| 42 | +``` |
| 43 | + |
| 44 | +You can check coverage and list specific missing lines with: |
| 45 | +``` |
| 46 | +pytest --cov=custom_components/pyscript --cov-report term-missing |
22 | 47 | ``` |
0 commit comments