Menu

[76e07a]: / runtests  Maximize  Restore  History

Download this file

37 lines (30 with data), 1.0 kB

#!/bin/sh

# Check for python3
command -v python3 >/dev/null 2>&1 || { echo >&2 "Tests require python3, which was not detected.  Aborting."; exit 1; }

TESTDIR=`dirname $0`/tests
TESTENV="$TESTDIR/testenv"

echo Setting up test execution environment...

# Check for virtual environment
if [ ! -d "$TESTENV" ]; then
    command -v virtualenv >/dev/null 2>&1
    if [ $? -eq 0 ]; then
        # Just use virtualenv.
        virtualenv -p `which python3` "$TESTENV" || exit 1
    else
        # Check for specific version
        python3 -c "import sys; sys.exit(0 if sys.version_info >= (3, 3, 0) else 1)"
        if [ $? -eq 0 ]; then
            # If at least 3.3, we can simply use venv module.
            python3 -m venv "$TESTENV" || exit 1
        else
            echo Please install virtualenv to run tests
            exit 1
        fi
    fi
fi

# Make sure requirements are up-to-date
"$TESTENV/bin/pip" install -r "$TESTDIR/requirements.txt"

# Run tests
echo Running tests...
cd $TESTDIR
testenv/bin/python -m unittest $* tests.py
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.