- Author:
- jacobian
- Posted:
- March 14, 2007
- Language:
- Python
- Version:
- Pre .96
- Score:
- 9 (after 9 ratings)
I'm posting this here mostly because I need a more permanent home for this than my lappy's hard drive. I hope it's interesting to other people, though.
Anyway - this script is what I use to test Django against multiple versions of Python and multiple databases. To actually run this you'll of course need Python 2.3, 2.4, and 2.5 installed along with MySQL, PostgreSQL, and sqlite3 -- and the associated database wrappers for all 3 Pythons.
Yes, for the record, I've got all those things installed on my laptop.
If you can somehow make that work, though, running this script will print out a nice little summary of what's failing against which versions of Python and which database. Run with -v
to see the actual failures.
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
- Template tag - list punctuation for a list of items by shapiromatron 11 months, 2 weeks ago
- JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 11 months, 3 weeks ago
- Serializer factory with Django Rest Framework by julio 1 year, 6 months ago
- Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 7 months ago
- Help text hyperlinks by sa2812 1 year, 7 months ago
Comments
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. :-)
#
Please login first before commenting.