File: testdb-setuptools

package info (click to toggle)
sqlobject 3.10.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,660 kB
  • sloc: python: 17,348; makefile: 162; sh: 95
file content (87 lines) | stat: -rw-r--r-- 1,603 bytes parent folder | download | duplicates (3)
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
87
#!/bin/bash

# Test that setuptools requirements are correct
# See #918683 for context of why we want this test

set -e

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

mkdir mypkg
mkdir mypkg/testlib
mkdir rundir3

cd mypkg

touch __init__.py

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

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

      install_requires="SQLObject",
      packages=find_packages(),
      zip_safe=True,

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

cd testlib
cat << EOF > base.py
from sqlobject import SQLObject, IntCol

class TestCol(SQLObject):

    number = IntCol()
EOF

cat << EOF > testdb.py
import sys

from sqlobject import connectionForURI, sqlhub, SQLObjectNotFound

from testlib.base import TestCol


def run():
    sqlhub.processConnection = connectionForURI('sqlite:///:memory:')
    TestCol.createTable()
    entry1 = TestCol(number=1)

    # Check we have the right number of entries
    if TestCol.select().count() != 1:
        return False

    # check we can select by number

    entry = TestCol.selectBy(number=1).getOne()
    if entry != entry1:
        return False
    return True


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

touch __init__.py

cd $WORKDIR
for py in $(py3versions -s) python3; do
   virtualenv -p $py testvenv --system-site-packages
   . testvenv/bin/activate
   python -m pip install ./mypkg
   testdb
   cd $WORKDIR
   deactivate
   rm -rf testvenv
done