Skip to content

Commit 50fcb13

Browse files
Update CONTRIBUTING.md
1 parent af7ba06 commit 50fcb13

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

CONTRIBUTING.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ If you're stuck, confused, or just don't know what to start with, our [Discord](
88

99
## Getting Started
1010

11-
Assuming you have Git installed, simply clone the repo and install view.py locally:
11+
Assuming you have Git installed, simply clone the repo and install view.py locally (under a virtual environment):
1212

1313
```
1414
$ git clone https://github.com/ZeroIntensity/view.py
1515
$ cd view.py
16+
$ python3 -m venv .venv
17+
$ source .venv/bin/activate
1618
$ pip install .
1719
```
1820

@@ -43,9 +45,12 @@ async def index():
4345
app.run()
4446
```
4547

46-
Note that you do need to `pip install .` to get your changes under the `view` module. However, waiting for pip every time can be a headache. Unless you're modifying the [C API](https://github.com/ZeroIntensity/view.py/tree/master/src/_view), you don't actually need it. Instead, you can test your code via just importing from `src.view`. For example:
48+
Note that you do need to `pip install .` to get your changes under the `view` module. However, waiting for pip every time can be a headache. Unless you're modifying the [C API](https://github.com/ZeroIntensity/view.py/tree/master/src/_view), you don't actually need it. Instead, you can test your code via just importing from `src.view`. A `test.py` file **should not** be inside of the `src/view` folder, but instead outside it (i.e. in the same directory as `src`).
49+
50+
For example, a simple `test.py` could look like:
4751

4852
```py
53+
# test.py
4954
from src.view import new_app
5055

5156
app = new_app()
@@ -57,6 +62,8 @@ async def index():
5762
app.run()
5863
```
5964

65+
**Note:** Import from `view` internally *does not* work when using `src.view`. Instead, your imports inside of view.py should look like `from .foo import bar`. For example, if you wanted to import `view.routing.get` from `src/view/app.py`, your import would look like `from .routing import get`
66+
6067
For debugging purposes, you're also going to want to disable `fancy` and `hijack` in the configuration:
6168

6269
```toml
@@ -65,6 +72,8 @@ fancy = false
6572
hijack = false
6673
```
6774

75+
These settings will stop view.py's fancy output from showing, as well as stopping the hijack of the `uvicorn` logger, and you'll get the raw `uvicorn` output.
76+
6877
## Writing Tests
6978

7079
**Note:** You do need to `pip install .` to update the tests, as they import from `view` and not `src.view`.
@@ -84,7 +93,7 @@ async def _():
8493

8594
async with app.test() as test:
8695
res = await test.get("/")
87-
assert res.test == "test"
96+
assert res.message == "test"
8897
```
8998

9099
In the above code, a server **would not** be started, and instead just virtualized for testing purposes.

0 commit comments

Comments
 (0)