#!/bin/sh

set -ex

# testsuite - run tests in our test environment

# This runs most unit tests from the source package. It does not run the
# doctests that are embedded in the source code itself.

# Copy the test suite to the temporary directory
cp -rp tests "$AUTOPKGTEST_TMP/"

# Prepare config for pytest
cat > "$AUTOPKGTEST_TMP/pytest.ini" << EOM
[pytest]
addopts = --doctest-glob="*.doctest" tests
doctest_optionflags = NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL
EOM

# Run the tests from the temporary directory
for py in $(py3versions -r 2>/dev/null);
do
  cd "$AUTOPKGTEST_TMP"
  echo "Testing with $py:"
  $py -m pytest
done
