Package: dh-python
Version: 5.20220119
Severity: wishlist

When configuring debian/tests for autopkgtest, sometimes it's
convenient to use the Test-Command: field in debian/tests/control to
use a simple single-line launch of tests (e.g. pytest-3 on its own),
rather than using the Tests: field and then having to set up a test
script separately.

With python packages, pytest-3 often works well as a single-line test
command.

The problem is that on its own pytest-3 only launches one python
version.  To test all available python versions a script would need to
be written to cycle through each of them.

dh-python could make the process simpler by providing the all-version
script itself, prividing a wrapper script that launches pytest-3 for
each python version.  This wrapper could then be invoked in the
Test-Command field in debian/tests/control

The script could be /usr/bin/dh_pytest-3.
It should pass on pytest options.
It might look something like

####################
PYTEST_OPTIONS=($1)

PY3VER=$( py3versions -sv )

for py in $PY3VER; do
  python$py -m pytest ${PYTEST_OPTIONS}
done
####################


With a bit more effort, more control of the python version could be
done, e.g. using the -d or -r options of py3versions,
but care would be needed to not mix that up with the pytest options.

Reply via email to