pybuild-autopkgtest(1)
π pybuild-autopkgtest π
okay bestie, this one lives in the General Commands Manual section, and it's genuinely one of the most "just vibes, no config" tools out there. it's called pybuild-autopkgtest and it's here to make your Debian packaging life so much easier. π«Ά
β¨ NAME β¨
pybuild-autopkgtest β invokes the test suite against requested Python versions and installed packages π
β¨ SYNOPSIS β¨
pybuild-autopkgtest
that's it. that's the whole call. iconic behavior honestly. π
β¨ OPTIONS β¨
bestie. listen. pybuild-autopkgtest takes no options or arguments. none. zero. nada. π
all configuration is done via the same mechanisms you use to control pybuild itself, namely:
- by having build dependencies on the right packages, or
- by setting
PYBUILD_*environment variables indebian/rules.
so if you were about to type --help and hope for a flag menuβ¦ no ma'am. the config is vibes-based and it's giving "read your build deps." πΈ
β¨ DESCRIPTION β¨
so pybuild-autopkgtest is an autopkgtest test runner that reuses all the pybuild infrastructure to run tests against installed packages, exactly the way autopkgtest expects. β¨
to enable it for your package you need to add this to the source stanza in debian/control:
Testsuite: autopkgtest-pkg-pybuild
and that alone will cause autodep8(1) to produce the correct contents for debian/tests/control. slay. π¦
pybuild-autopkgtest will run the tests in exactly the same way pybuild will during the build β with one exception: the tests are not run in the build directory. instead, the test files get copied to a temporary directory, so the tests run against the installed Python modules and not against anything sitting around in your source tree. that's the whole point. π
because all the pybuild infrastructure is used, for most packages you don't need to add any extra code to configure pybuild-autopkgtest. for example: just having python3-pytest as a build dependency is enough to make the test runner use pytest to run the tests. that's it. no extra config. no cap. π
the tests are executed via a temporary makefile that includes debian/rules from the package β so any environment variables defined there will also be available during autopkgtest, including but not limited to PYBUILD_* variables for configuring the behavior of pybuild itself. cute AND functional. π
β¨ ADOPTING PYBUILD-AUTOPKGTEST β¨
since pybuild-autopkgtest reuses environment variables set in debian/rules, migrating packages over to it should not require much effort. lowkey a free win. π«Ά
maybe you have a debian/tests/control that already does what pybuild-autopkgtest does β like copying the test files to a temporary directory, cd-ing into it, and running the tests from there. bestie, those test entries can usually be removed in favor of just adding:
Testsuite: autopkgtest-pkg-pybuild
to debian/control. bye redundant boilerplate. π
in general, you want to move any test-related command line arguments to pybuild into environment variables in debian/rules. that's the move.
you can also keep specialized, manually-written test cases alongside the ones autogenerated by autodep8. for that, you do both: set
Testsuite: autopkgtest-pkg-pybuild
in debian/control and keep your custom tests in debian/tests/control. both. at the same time. main character energy. π
β¨ VARYING BEHAVIOR UNDER AUTOPKGTEST β¨
ideally, the behavior of the tests should be the same during the build and under autopkgtest β except for the fact that during autopkgtest the tests should load the code from the installed package. pybuild-autopkgtest should do this correctly most of the time. β¨
there are situations, however, where you need a slightly different behavior during the autopkgtest run. there are a few mechanisms to support that: π
pybuild-autopkgtestsets thePYBUILD_AUTOPKGTESTenvironment variable to1during the test run. this way, you can add conditional behavior indebian/rules. π- before and after running the tests,
pybuild-autopkgtestwill call thedebian/rulestargetsbefore-pybuild-autopkgtestandafter-pybuild-autopkgtest, respectively, if they exist. π
β¨ SAMPLE TEST CONTROL FILE β¨
the control file produced by autodep8(1) looks like this:
Test-Command: pybuild-autopkgtest
Depends: @, @builddeps@,
Restrictions: allow-stderr, skippable,
Features: test-name=pybuild-autopkgtest
bestie, you should never need to hardcode this in debian/tests/control. let autodep8 cook. π
you can add extra items to Restrictions and Depends by providing a configuration file for autodep8 at debian/tests/autopkgtest-pkg-pybuild.conf, like this:
extra_depends=foo, bar
extra_restrictions=isolation-container, breaks-testbed
you can also limit the set of supported architectures in that same file:
architecture=any-amd64 s390x
β¨ SEE ALSO β¨
β¨ AUTHOR β¨
Antonio Terceiro, 2021 β thank you for this gift, we are obsessed. π«Άπ
okay that's the whole page bestie!! go run your tests against installed packages and thrive. the source/version line at the bottom of this manpage is just pybuild-autopkgtest(1), and the author credit on the tin is Antonio Terceiro, 2021 β so shout them out when you ship. byeeee π
β¨π
π¦ where this page comes from
- ubuntu stonking: dh-python 7.20260623ubuntu2 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms