#!/bin/bash

# Use test.tar.xz from /usr/share/doc/pycorrfit/examples/ if executed with
# autopkgtest
set -e
pkg=pycorrfit
export PYTHONPATH=/usr/lib/${pkg}
examplesdir=/usr/share/doc/${pkg}/examples
TMPDIR=$(mktemp -d)
trap "rm -rf $TMPDIR" 0 INT QUIT ABRT PIPE TERM
tar -xf ${examplesdir}/tests.tar.xz -C $TMPDIR
WORKDIR=${TMPDIR}

cd $WORKDIR

# Skip tests which need network access

rm -vf tests/{test_constraints.py,test_file_formats.py,test_session.py}
find tests -print

python3 -m pytest tests

rm -rf $WORKDIR
