Skip to content

Commit

Permalink
Fixed #19192 -- Allowed running tests with dummy db backend
Browse files Browse the repository at this point in the history
Thanks Simon Charette for the initial patch, and Jan Bednařík for
his work on the ticket.
  • Loading branch information
claudep committed Jan 4, 2013
1 parent 850630b commit b740da3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ answer newbie questions, and generally made Django that much better:
Chris Chamberlin <dja@cdc.msbx.net> Chris Chamberlin <dja@cdc.msbx.net>
Amit Chakradeo <http://amit.chakradeo.net/> Amit Chakradeo <http://amit.chakradeo.net/>
ChaosKCW ChaosKCW
Simon Charette <charette.s@gmail.com>
Kowito Charoenratchatabhan <kowito@felspar.com> Kowito Charoenratchatabhan <kowito@felspar.com>
Sengtha Chay <sengtha@e-khmer.com> Sengtha Chay <sengtha@e-khmer.com>
ivan.chelubeev@gmail.com ivan.chelubeev@gmail.com
Expand Down
6 changes: 5 additions & 1 deletion django/db/backends/dummy/base.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class DatabaseOperations(BaseDatabaseOperations):
class DatabaseClient(BaseDatabaseClient): class DatabaseClient(BaseDatabaseClient):
runshell = complain runshell = complain


class DatabaseCreation(BaseDatabaseCreation):
create_test_db = ignore
destroy_test_db = ignore

class DatabaseIntrospection(BaseDatabaseIntrospection): class DatabaseIntrospection(BaseDatabaseIntrospection):
get_table_list = complain get_table_list = complain
get_table_description = complain get_table_description = complain
Expand Down Expand Up @@ -64,6 +68,6 @@ def __init__(self, *args, **kwargs):
self.features = BaseDatabaseFeatures(self) self.features = BaseDatabaseFeatures(self)
self.ops = DatabaseOperations(self) self.ops = DatabaseOperations(self)
self.client = DatabaseClient(self) self.client = DatabaseClient(self)
self.creation = BaseDatabaseCreation(self) self.creation = DatabaseCreation(self)
self.introspection = DatabaseIntrospection(self) self.introspection = DatabaseIntrospection(self)
self.validation = BaseDatabaseValidation(self) self.validation = BaseDatabaseValidation(self)
18 changes: 18 additions & 0 deletions tests/regressiontests/test_runner/tests.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -261,6 +261,24 @@ def test_transaction_support(self):
db.connections = old_db_connections db.connections = old_db_connections




class DummyBackendTest(unittest.TestCase):
def test_setup_databases(self):
"""
Test that setup_databases() doesn't fail with dummy database backend.
"""
runner = DjangoTestSuiteRunner(verbosity=0)
old_db_connections = db.connections
try:
db.connections = db.ConnectionHandler({})
old_config = runner.setup_databases()
runner.teardown_databases(old_config)
except Exception as e:
self.fail("setup_databases/teardown_databases unexpectedly raised "
"an error: %s" % e)
finally:
db.connections = old_db_connections


class AutoIncrementResetTest(TransactionTestCase): class AutoIncrementResetTest(TransactionTestCase):
""" """
Here we test creating the same model two times in different test methods, Here we test creating the same model two times in different test methods,
Expand Down

0 comments on commit b740da3

Please sign in to comment.