Improved unit-test framework so that it handles database errors more elegantly
git-svn-id: http://code.djangoproject.com/svn/django/trunk@446 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
270234d189
commit
fd579f24d7
|
@ -111,7 +111,12 @@ class TestRunner:
|
||||||
# has side effects on doctest TestRunner class.
|
# has side effects on doctest TestRunner class.
|
||||||
runner = DjangoDoctestRunner(verbosity_level=verbosity_level, verbose=False)
|
runner = DjangoDoctestRunner(verbosity_level=verbosity_level, verbose=False)
|
||||||
self.output(1, "%s model: Running tests" % model_name)
|
self.output(1, "%s model: Running tests" % model_name)
|
||||||
runner.run(dtest, clear_globs=True, out=sys.stdout.write)
|
try:
|
||||||
|
runner.run(dtest, clear_globs=True, out=sys.stdout.write)
|
||||||
|
finally:
|
||||||
|
# Rollback, in case of database errors. Otherwise they'd have
|
||||||
|
# side effects on other tests.
|
||||||
|
db.rollback()
|
||||||
|
|
||||||
# Run the non-model tests in the other tests dir
|
# Run the non-model tests in the other tests dir
|
||||||
self.output(1, "Running other tests")
|
self.output(1, "Running other tests")
|
||||||
|
|
Loading…
Reference in New Issue