File: testfe-setuptools

package info (click to toggle)
python-formencode 2.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,844 kB
  • sloc: python: 7,032; makefile: 139; sh: 96; javascript: 61
file content (86 lines) | stat: -rw-r--r-- 1,430 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
79
80
81
82
83
84
85
86
#!/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

cat << EOF > pyproject.toml
[build-system]
requires = ["setuptools"]
EOF

touch __init__.py

cd $WORKDIR

for py in $(py3versions -s) python3; do
   virtualenv -p $py testve
   testve/bin/python -m pip install --no-warn-script-location ./mypkg
   testve/bin/testfe
done