#!/bin/sh

set -Ceu

: ${MAKE:=make}
: ${PYTHON:=python}

root=`cd -- "$(dirname -- "$0")" && pwd`

(
    set -Ceu
    cd -- "${root}"
    rm -rf build
    ./pythenv.sh "$PYTHON" setup.py build
    if [ $# -eq 0 ]; then
        ./pythenv.sh "$PYTHON" -m pytest \
            src/tests/unit_tests \
            # end of tests
    else
        ./pythenv.sh "$PYTHON" -m pytest "$@"
    fi
)

if cd cpp_code && "${MAKE}" runtests; then
    echo 'Passed!'
else
    status=$?
    echo 'Failed!'
    exit $status
fi

#!/bin/sh

set -Ceu

: ${MAKE:=make}
: ${PYTHON:=python}
: ${PY_TEST:=py.test}
case $PY_TEST in */*);; *) PY_TEST=`which "$PY_TEST"` || PY_TEST=;; esac

if [ ! -x "${PY_TEST}" ]; then
    printf >&2 'unable to find pytest\n'
    exit 1
fi

root=`cd -- "$(dirname -- "$0")" && pwd`

(
    set -Ceu
    cd -- "${root}"
    rm -rf build
    ./pythenv.sh "$PYTHON" setup.py build
    if [ $# -eq 0 ]; then
        ./pythenv.sh "$PYTHON" "$PY_TEST" \
            src/tests/unit_tests \
            # end of tests
    else
        ./pythenv.sh "$PYTHON" "$PY_TEST" "$@"
    fi
)

if cd cpp_code && "${MAKE}" runtests; then
    echo 'Passed!'
else
    status=$?
    echo 'Failed!'
    exit $status
fi

--- 
+++ 
@@ -4,13 +4,6 @@
 
 : ${MAKE:=make}
 : ${PYTHON:=python}
-: ${PY_TEST:=py.test}
-case $PY_TEST in */*);; *) PY_TEST=`which "$PY_TEST"` || PY_TEST=;; esac
-
-if [ ! -x "${PY_TEST}" ]; then
-    printf >&2 'unable to find pytest\n'
-    exit 1
-fi
 
 root=`cd -- "$(dirname -- "$0")" && pwd`
 
@@ -20,11 +13,11 @@
     rm -rf build
     ./pythenv.sh "$PYTHON" setup.py build
     if [ $# -eq 0 ]; then
-        ./pythenv.sh "$PYTHON" "$PY_TEST" \
+        ./pythenv.sh "$PYTHON" -m pytest \
             src/tests/unit_tests \
             # end of tests
     else
-        ./pythenv.sh "$PYTHON" "$PY_TEST" "$@"
+        ./pythenv.sh "$PYTHON" -m pytest "$@"
     fi
 )
 
Use `python -m pytest' instead of `python $(which py.test)'.
