This document is intended for developers only.
Install dependencies into your current Python environment: pip install .
Aside from that, you will need to install other dependencies listed in .appveyor.yml
(e.g., Ncat; for Debian-based distros try apt install ncat
).
Write unit tests as functions without arguments prefixed with _unittest_
;
optionally, for slow test functions use the prefix _unittest_slow_
.
Generally, simple test functions should be located as close as possible to the tested code,
preferably at the end of the same Python module.
The directory tests/deps
contains various test dependencies, including sitecustomize.py
,
which is used to measure code coverage in subprocesses (which the test suite spawns a lot of, naturally).
When running tests on GNU/Linux, ensure either that the current user is allowed to use sudo
without an
interactive password prompt; or, when you're around, you can also enter the password when prompted.
This is needed for setting up vcan
interfaces, loading relevant kernel modules, and setting up packet capture.
Install Nox: pip install nox
Run the test suite and linters, abort on first failure:
nox -xs test lint
Nox is configured to reuse existing virtualenv to accelerate interactive testing.
If you want to start from scratch, use clean
:
nox -s clean
Running the full test suite using Nox takes too much time for interactive testing during development. A more interactive approach is as follows:
- Be in the yakut root directory.
- Run the long test session once with
nox
. - Change directory to
.nox/test-3-8/tmp
, here substitutetest-3-8
for the directory you have. This is one of the environments that Nox creates for testing. - Run
source ../bin/activate
to activate the virtualenv. export PYTHONPATH=.compiled/
- Run specific commands you need:
pytest ../../../yakut/whatever
,mypy --strict ../../../yakut ../../../tests
, etc.
When you want to run say unit tests at the end of the yakut/param/formatter.py
file:
- Make sure
nox
has been run before, this creates the test environment(s). - Activate one of the nox test environments like
source .nox/test-3-8/bin/activate
pytest yakut/param/formatter.py
Some tools with rich UI are difficult to test automatically.
To look for manual tests in the codebase, please search for def _main
under tests/
.
We recommend JetBrains PyCharm for development.
The test suite stores compiled DSDL into .compiled/
in the current working directory
(when using Nox, the current working directory may be under a virtualenv private directory).
Make sure to mark it as a source directory to enable code completion and type analysis in the IDE
(for PyCharm: right click -> Mark Directory As -> Sources Root).
Alternatively, you can just compile DSDL manually directly in the project root.
Configure the IDE to run Black on save. See the Black documentation for integration instructions.
Capture desktop region:
ffmpeg -video_size 1920x1500 -framerate 10 -f x11grab -i :0.0+3840,117 output.mp4 -y
Convert captured video to GIF:
ffmpeg -i output.mp4 output.gif
Stream webcam via MJPEG using VLC (open the stream using web browser or VLC):
cvlc v4l2:///dev/video0 :chroma=mjpg :live-caching=10 --sout '#transcode{vcodec=mjpg}:std{access=http{mime=multipart/x-mixed-replace;boundary=-7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=0.0.0.0:8080}' --network-caching=0
The tool is versioned by following Semantic Versioning.
For all commits pushed to master, the CI/CD pipeline automatically uploads a new release to PyPI
and pushes a new tag upstream.
It is therefore necessary to ensure that the library version (see yakut/VERSION
) is bumped whenever
a new commit is merged into master;
otherwise, the automation will fail with an explicit tag conflict error instead of deploying the release.