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