Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Improved unit-test framework so that it handles database errors more …


git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit fd579f24d79ac70f8339f1544f2c3707cf468800 1 parent 270234d
@adrianholovaty adrianholovaty authored
Showing with 8 additions and 3 deletions.
  1. +8 −3 tests/
11 tests/
@@ -111,8 +111,13 @@ def run_tests(self):
# has side effects on doctest TestRunner class.
runner = DjangoDoctestRunner(verbosity_level=verbosity_level, verbose=False)
self.output(1, "%s model: Running tests" % model_name)
-, clear_globs=True, out=sys.stdout.write)
+ try:
+, 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
self.output(1, "Running other tests")
other_tests_dir = os.path.join(os.path.dirname(__file__), OTHER_TESTS_DIR)
@@ -137,7 +142,7 @@ def run_tests(self):
except Exception, e:
log_error(module, "Exception running tests", ''.join(traceback.format_exception(*sys.exc_info())[1:]))
# Unless we're using SQLite, remove the test database to clean up after
# ourselves. Connect to the previous database (not the test database)
# to do so, because it's not allowed to delete a database while being

0 comments on commit fd579f2

Please sign in to comment.
Something went wrong with that request. Please try again.