File: testfe-setuptools

package info (click to toggle)
python-formencode 2.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,828 kB
  • sloc: python: 6,964; makefile: 121; sh: 89; javascript: 61
file content (78 lines) | stat: -rw-r--r-- 1,256 bytes parent folder | download
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/sh

# Test that setuptools requirements are correct

set -e

WORKDIR=$(mktemp -d)
trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
cd $WORKDIR

mkdir mypkg
mkdir mypkg/testlib

cd mypkg

touch __init__.py

cat << EOF > setup.py
from setuptools import setup, find_packages

setup(name="testlib",
      version="0.0.1",
      description="Test formencode with setuptools requires",

      install_requires="FormEncode>=2.0.0",
      packages=find_packages(),
      zip_safe=True,

      entry_points={
          'console_scripts': ['testfe=testlib.testfe:main'],
      },
)
EOF

cd testlib
cat << EOF > base.py
from formencode.validators import Int

check = Int(min=0, max=10)

EOF

cat << EOF > testfe.py
import sys

from formencode.api import Invalid

from testlib.base import check

def run():
    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


def main():
    if not run():
        sys.exit(1)
EOF

touch __init__.py

cd $WORKDIR/mypkg
python3 ./setup.py install --user
cd ~/.local/bin
./testfe