File: testdb-setuptools

package info (click to toggle)
sqlobject 3.7.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,696 kB
  • sloc: python: 16,944; makefile: 160; sh: 94
file content (89 lines) | stat: -rw-r--r-- 1,643 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
87
88
89
#!/bin/sh

# 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 rundir
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(),

      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/mypkg
export PYTHONPATH=$WORKDIR/rundir
python ./setup.py develop -d $WORKDIR/rundir
cd $WORKDIR/rundir
./testdb

# Repeat with python 3
cd $WORKDIR/mypkg
export PYTHONPATH=$WORKDIR/rundir3
python3 ./setup.py develop -d $WORKDIR/rundir3
cd $WORKDIR/rundir3
./testdb