File: runtests.py

package info (click to toggle)
sqlkit 0.9.5-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 8,184 kB
  • sloc: python: 17,477; sql: 166; makefile: 95; xml: 23; sh: 11
file content (54 lines) | stat: -rwxr-xr-x 1,098 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/python

import os
import sys
import doctest
import sqlite3
from contextlib import closing
import tempfile

import babel

pdir = os.path.dirname(os.getcwd())
ppdir = os.path.dirname(pdir)
sys.path.insert(0,pdir)    
sys.path.insert(0,ppdir)    

DB_FILE = os.path.join(tempfile.gettempdir(), 'db-%s.sqlite' % os.environ.get('USERNAME'))
DB_SCHEMA = '../../demo/sql/model/schema.sql'

def init_db():
    if os.path.exists(DB_FILE):
        os.remove(DB_FILE)
    with closing(sqlite3.connect(DB_FILE)) as db:
        with open(DB_SCHEMA, 'r') as schema:
            db.cursor().executescript(schema.read())
        db.commit()
init_db()


os.environ['LANG'] = 'C'
os.environ['LANG'] = 'en_US.utf8'
doctest.ELLIPSIS = 10

files = (
    'completions.txt',
    'dates.txt',
    'defaults.txt',
    'django2sa.txt',
    'fields.txt',
    'filters.txt',
    'mapper_inspect.txt',
    'mask.txt',
    )

if sys.argv[1:]:
    files = sys.argv[1:]

for filename in files:
    print filename
    os.environ['LANG'] = 'en_US.utf8'
    doctest.testfile(filename, optionflags=doctest.ELLIPSIS)