Validation and testing

Check Python sources

The Python files can be byte-compiled without starting the service:

python3 -m compileall -q helloworld_python_binding tests
python3 -m py_compile bin/helloworld-python-binding

The repository lint helper performs these checks as part of make lint.

Test strategy

The project provides functional tests and a redtest integration for execution in redpesk validation workflows.

Each functional test runs in a fresh child process with its own AFB binder. The Python helloworld API is created directly in that binder, avoiding transport-specific differences from an intermediate API proxy.

The tests cover:

  • hello replies with and without parameters;
  • representative hello argument conversion, including long replies;
  • valid and invalid sum requests;
  • signed 64-bit wrapping behavior;
  • the generated info verb;
  • verb_called event emission.

Test dependencies

The functional tests require Python 3 and afb-libpython.

First prepare the AFB development environment by following Build framework on your computer.

When using an RPM-based redpesk development environment, the Python dependencies can alternatively be installed with:

sudo dnf install python3 afb-libpython

Run the functional tests

Use the repository helper:

./tests/run.sh

Or execute the test module directly:

python3 ./tests/tests.py

To produce TAP output:

python3 ./tests/tests.py --tap

A successful run reports all test cases as successful.

Run lint checks

The lint helper byte-compiles the Python sources and rejects tab characters in Python and shell sources:

./tests/ci/lint.sh

It can also be invoked through the Makefile:

make lint

The repository-level markdown configuration excludes the Apache LICENSE text from Markdown linting because the license is not a Markdown document.

redtest package

The RPM specification provides the helloworld-python-binding-redtest subpackage. It contains:

  • tests.py;
  • the run-redtest entry point.

Install it together with the service on a compatible redpesk test environment:

dnf install helloworld-python-binding helloworld-python-binding-redtest

The installed test entry point is:

/usr/libexec/redtest/helloworld-python-binding/run-redtest

It can be executed directly with:

/usr/libexec/redtest/helloworld-python-binding/run-redtest

Test artifacts

The redtest runner writes the TAP result to:

/var/log/redtest/helloworld-python-binding/helloworld-python.tap

The runner returns a failure status when the TAP report contains a not ok result, allowing it to be integrated into automated validation pipelines.

Unlike the C sample, this Python RPM does not currently generate native code-coverage data. Consequently, the C project’s no_coverage build condition is intentionally not duplicated here.