1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
#!/bin/sh
# Simple test that we can call a simple validator
set -e
WORKDIR=$(mktemp -d)
trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
cd $WORKDIR
cat << EOF > testfe.py
import sys
from formencode.validators import Int
from formencode.api import Invalid
def run():
check = Int(min=0, max=10)
if check.to_python('5') != 5:
return False
# Check too large
try:
check.to_python('11')
return False
except Invalid:
pass
# Check too small
try:
check.to_python('-1')
return False
except Invalid:
pass
return True
if __name__ == "__main__":
if not run():
sys.exit(1)
EOF
for py in $(py3versions -s) python3; do
$py testfe.py
done
|