Test Django against many Pythons and databases

 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
#!/usr/bin/env python

import re
import sys
import optparse
import subprocess
from unipath import FSPath as Path # http://cheeseshop.python.org/pypi/Unipath

PYTHONS = ["2.3", "2.4", "2.5"]
DBS = ["postgres", "mysql", "sqlite"]

p = optparse.OptionParser()
p.add_option("-p", "--python", action="append")
p.add_option("-d", "--db", action="append")
p.add_option("-v", "--verbose", action="store_true")
p.set_defaults(python=[], db=[], verbose=False)
options, args = p.parse_args()

if not options.python: options.python = PYTHONS
if not options.db: options.db = DBS

sys.path.append(Path(__file__).parent)

for py in options.python:
    for db in options.db:
        if options.verbose:
            print "#"*80
            print "Runing tests using Python %s / %s:" % (py, db)
        pipe = subprocess.Popen(
            ["python%s" % py, "runtests.py", "--settings=testsettings.%s" % db] + args, 
            stdout  = subprocess.PIPE, 
            stderr  = subprocess.STDOUT, 
            cwd     = Path(__file__).parent.child("django.trunk").child("tests"),
        )
        out, err = pipe.communicate()
        if options.verbose:
            print out
        else:
            outlines = out.split("\n")
            failures = [l for l in outlines if re.match("^(FAIL|ERROR): ", l)]
            lastline = out.split("\n")[-2]
            print "Python %s / %s: %s" % (py, db, lastline)
            if failures:
                for f in failures:
                    print "\t%s" % f
                print

More like this

  1. Compact list_filter by onlinehero 4 years, 3 months ago
  2. Table Creation Using ORM Standalone by EliAndrewC 6 years, 2 months ago
  3. Test Server Thread by adamlofts 4 years, 10 months ago
  4. Testing with unmanaged models by manfre 4 years, 10 months ago
  5. immitating 'real' post_syncdb signal by jango 4 years ago

Comments

mboersma (on April 12, 2007):

Thanks, Jacob. I'm running this script against all three pythons and all the DB drivers you are, plus psycopg2 and Oracle. My laptop gets a workout.

Nyah, nyah. :-)

#

(Forgotten your password?)