#!/bin/bash # Run build-time tests in build-time testdir, # to avoid test output files appear in the build_dir # (which is installed to the debian package) # # build_dir is provided as an argument to this script. # No action is taken if it is not provided build_dir=$1 if [ "x$build_dir" != "x" ]; then # monkeypatch suggested at https://stackoverflow.com/a/62055409/12401525 cat >$build_dir/conftest.py << END import pytest @pytest.fixture(autouse=True) def change_test_dir(request, monkeypatch): monkeypatch.chdir(request.fspath.dirname) END fi