|
| 1 | +# Setup the environment |
| 2 | + |
| 3 | +1. Clone the repo: `git clone [email protected]:python-lsp/python-lsp-server.git` |
| 4 | +2. Create the virtual environment: `python -m venv .venv` |
| 5 | +3. Activate: `source .venv/bin/activate` |
| 6 | +4. Install an editable installation: `pip install -e .` |
| 7 | + - This will ensure you'll see your edits immediately without reinstalling the project |
| 8 | +5. Configure your editor to point the pylsp executable to the one in `.venv` |
| 9 | + |
| 10 | +## Trying out if it works |
| 11 | + |
| 12 | +Go to file `pylsp/python_lsp.py`, function `start_io_lang_server`, |
| 13 | +and on the first line of the function, add some logging: |
| 14 | + |
| 15 | +```py |
| 16 | +log.info("It works!") |
| 17 | +``` |
| 18 | + |
| 19 | +Save the file, restart the LSP server and you should see the log line: |
| 20 | + |
| 21 | +``` |
| 22 | +2023-10-12 16:46:38,320 CEST - INFO - pylsp._utils - It works! |
| 23 | +``` |
| 24 | + |
| 25 | +Now the project is setup in a way you can quickly iterate change you want to add. |
| 26 | + |
| 27 | +# Running tests |
| 28 | + |
| 29 | +1. Install runtime dependencies: `pip install .[all]` |
| 30 | +2. Install test dependencies: `pip install .[test]` |
| 31 | +3. Run `pytest`: `pytest -v` |
| 32 | + |
| 33 | +## Useful pytest options |
| 34 | + |
| 35 | +- To run a specific test file, use `pytest test/test_utils.py` |
| 36 | +- To run a specific test function within a test file, |
| 37 | + use `pytest test/test_utils.py::test_debounce` |
| 38 | +- To run tests matching a certain expression, use `pytest -k format` |
| 39 | +- To increase verbosity of pytest, use `pytest -v` or `pytest -vv` |
| 40 | +- To enter a debugger on failed tests, use `pytest --pdb` |
0 commit comments