pybuild-autopkgtest(1)

πŸ“¦
version 7.20260623ubuntu2 Β· 2 versions
, in ubuntu stonking

πŸ’– 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 in debian/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-autopkgtest sets the PYBUILD_AUTOPKGTEST environment variable to 1 during the test run. this way, you can add conditional behavior in debian/rules. πŸ’–
  • before and after running the tests, pybuild-autopkgtest will call the debian/rules targets before-pybuild-autopkgtest and after-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