Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for REUSE_DB problems #101

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions django_nose/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,15 @@ def _skip_create_test_db(self, verbosity=1, autoclobber=False):

"""
# Notice that the DB supports transactions. Originally, this was done in
# the method this overrides. Django v1.2 does not have the confirm
# function. Added in https://code.djangoproject.com/ticket/12991.
# the method this overrides. The confirm method was added in Django v1.3
# (https://code.djangoproject.com/ticket/12991) but removed in Django v1.5
# (https://code.djangoproject.com/ticket/17760). In Django v1.5
# supports_transactions is a cached property evaluated on access.
if callable(getattr(self.connection.features, 'confirm', None)):
# Django v1.3-4
self.connection.features.confirm()
else:
elif hasattr(self, "_rollback_works"):
# Django v1.2 and lower
can_rollback = self._rollback_works()
self.connection.settings_dict['SUPPORTS_TRANSACTIONS'] = can_rollback

Expand Down Expand Up @@ -275,6 +279,11 @@ def _should_create_database(connection):

# Notice whether the DB exists, and create it if it doesn't:
try:
# Connections are cached by some backends, if other code has connected
# to the database previously under a different database name the
# cached connection will be used and no exception will be raised.
# Setting to null here solves that problem.
connection.connection = None
connection.cursor()
except StandardError: # TODO: Be more discerning but still DB agnostic.
return True
Expand Down