1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#!/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
|