| 1 | # Developer notes |
| 2 | |
| 3 | Friendly has no other dependencies than modules included in |
| 4 | Python's standard library. Python versions supported include 3.6, to 3.12 inclusively. |
| 5 | |
| 6 | We use [black](https://github.com/python/black) for formatting and |
| 7 | [flake8](http://flake8.pycqa.org/en/latest/) for linting. |
| 8 | We also use [pytest](https://docs.pytest.org/en/latest/) for testing. |
| 9 | |
| 10 | You can use `tox -p auto` to run black, flake8, and pytest in parallel. |
| 11 | |
| 12 | Before submitting code, you should ensure that it conforms to the |
| 13 | formatting requirements and that all tests pass. Feel free to include |
| 14 | additional unit tests. |
| 15 | |
| 16 | Currently, the code is only tested on Windows locally although |
| 17 | some github actions are used to run unit tests for Ubuntu and MacOS. |
| 18 | The repository includes some batch (`.bat`) files which help to |
| 19 | automate some processes, and are described later in this document. |
| 20 | |
| 21 | |
| 22 | ## Using virtual environments |
| 23 | |
| 24 | In this section we document our use of virtual environments and naming |
| 25 | convention; the naming convention is only useful if you wish to make use |
| 26 | of the existing batch files. |
| 27 | |
| 28 | 1. Create a virtual environment for a given Python version: |
| 29 | |
| 30 | py -3.7 -m venv ./venv-friendly-traceback-3.7 |
| 31 | |
| 32 | 2. Activate the virtual environment; on Windows you can use |
| 33 | |
| 34 | ae 3.7 |
| 35 | |
| 36 | Otherwise, you can presumably do something like: |
| 37 | |
| 38 | venv-friendly-tracceback-3.7/scripts/activate |
| 39 | |
| 40 | 3. Install the required dependencies for formatting, linting and testing |
| 41 | |
| 42 | python -m pip install -r requirements-dev.txt |
| 43 | |
| 44 | |
| 45 | 4. If desired, deactivate the virtual environment and create new ones for |
| 46 | other Python versions |
| 47 | |
| 48 | deactivate |
| 49 | py -3.6 -m venv ./venv-friendly-traceback-3.6 |
| 50 | |
| 51 | etc. |
| 52 | |
| 53 | ## Existing batch files |
| 54 | |
| 55 | 1. ae.bat |
| 56 | |
| 57 | Used to activate a virtual environment based on the Python version; |
| 58 | currently Python 3.10 is the default. Example usage: |
| 59 | |
| 60 | ae 3.6 |
| 61 | |
| 62 | 2. make_trb.bat |
| 63 | |
| 64 | Used to create rst traceback files for the documentation. This assumes |
| 65 | that a second repository exists and is found at the same directory level. |
| 66 | No one but the repository owner should likely worry about this. |
| 67 | It requires that Sphinx be installed in the default Python version. |
| 68 | |
| 69 | 3. pypi_upload.bat |
| 70 | |
| 71 | Script to upload to pypi; please ignore. |
| 72 | |
| 73 | 4. run_tests.bat |
| 74 | |
| 75 | Script to run the tests in all supported Python version, changing |
| 76 | virtual environment as needed. |
| 77 | |
| 78 | |
| 79 | ## Test coverage |
| 80 | |
| 81 | Install pytest-cov and run the following: |
| 82 | |
| 83 | python -m pytest --cov=friendly_traceback --cov-report html |
| 84 | switch environment for another python version. |
| 85 | python -m pytest --cov=friendly_traceback --cov-append --cov-report html |
| 86 | |
| 87 | ## Running a single test |
| 88 | |
| 89 | It is often useful to run a single test case as you develop. |
| 90 | From the root directory, you can do something like the following: |
| 91 | |
| 92 | pytest -k Text_in_function_name |
| 93 |