Skip to content

Commit d55b40f

Browse files
committed
added pre-commit install instructions
1 parent dd06f57 commit d55b40f

File tree

3 files changed

+40
-13
lines changed

3 files changed

+40
-13
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -818,9 +818,10 @@ changes will be lost, since reloading a script file recreates a new global conte
818818

819819
## Contributing
820820

821-
Contributions are welcome! You are encouraged to submit PRs, bug reports, feature requests or
822-
add to the Wiki with examples and tutorials. It would be fun to hear about unique and clever
823-
applications you develop.
821+
Contributions are welcome! You are encouraged to submit PRs, bug reports, feature requests or add to
822+
the Wiki with examples and tutorials. It would be fun to hear about unique and clever applications
823+
you develop. Please see this [README](https://github.com/custom-components/pyscript/tree/master/tests)
824+
for setting up a development environment and running tests.
824825

825826
## Useful Links
826827

requirements_test.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
croniter==0.3.34
1+
croniter>=0.3.34
2+
pre-commit
23
pytest
3-
pytest-cov==2.9.0
4+
pytest-cov>=2.9.0
45
pytest-homeassistant

tests/README.md

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,47 @@
1-
# Pyscript tests
1+
# Pyscript Development Setup
22

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:
44
```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
612
source venv/bin/activate
713
```
814

9-
Install needed dependencies:
15+
Finally, install the requirements and the pre-commit hooks:
1016
```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
1233
```
1334

1435
Now you can run the tests using this command:
1536
```bash
1637
pytest
1738
```
18-
19-
Always remember to activate the virtualenv before running anything:
39+
or run a specific test file with:
2040
```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
2247
```

0 commit comments

Comments
 (0)