Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.5.x] Fixed #19192 -- Allowed running tests with dummy db backend

Thanks Simon Charette for the initial patch, and Jan Bednařík for
his work on the ticket.
Backport of b740da3 from master.
  • Loading branch information...
commit 96301d21bb2ec7c5e06e3cea54fa2cdcd25a464d 1 parent b641357
Claude Paroz authored January 04, 2013
1  AUTHORS
@@ -125,6 +125,7 @@ answer newbie questions, and generally made Django that much better:
125 125
     Chris Chamberlin <dja@cdc.msbx.net>
126 126
     Amit Chakradeo <http://amit.chakradeo.net/>
127 127
     ChaosKCW
  128
+    Simon Charette <charette.s@gmail.com>
128 129
     Kowito Charoenratchatabhan <kowito@felspar.com>
129 130
     Sengtha Chay <sengtha@e-khmer.com>
130 131
     ivan.chelubeev@gmail.com
6  django/db/backends/dummy/base.py
@@ -31,6 +31,10 @@ class DatabaseOperations(BaseDatabaseOperations):
31 31
 class DatabaseClient(BaseDatabaseClient):
32 32
     runshell = complain
33 33
 
  34
+class DatabaseCreation(BaseDatabaseCreation):
  35
+    create_test_db = ignore
  36
+    destroy_test_db = ignore
  37
+
34 38
 class DatabaseIntrospection(BaseDatabaseIntrospection):
35 39
     get_table_list = complain
36 40
     get_table_description = complain
@@ -64,6 +68,6 @@ def __init__(self, *args, **kwargs):
64 68
         self.features = BaseDatabaseFeatures(self)
65 69
         self.ops = DatabaseOperations(self)
66 70
         self.client = DatabaseClient(self)
67  
-        self.creation = BaseDatabaseCreation(self)
  71
+        self.creation = DatabaseCreation(self)
68 72
         self.introspection = DatabaseIntrospection(self)
69 73
         self.validation = BaseDatabaseValidation(self)
18  tests/regressiontests/test_runner/tests.py
@@ -261,6 +261,24 @@ def test_transaction_support(self):
261 261
                 db.connections = old_db_connections
262 262
 
263 263
 
  264
+class DummyBackendTest(unittest.TestCase):
  265
+    def test_setup_databases(self):
  266
+        """
  267
+        Test that setup_databases() doesn't fail with dummy database backend.
  268
+        """
  269
+        runner = DjangoTestSuiteRunner(verbosity=0)
  270
+        old_db_connections = db.connections
  271
+        try:
  272
+            db.connections = db.ConnectionHandler({})
  273
+            old_config = runner.setup_databases()
  274
+            runner.teardown_databases(old_config)
  275
+        except Exception as e:
  276
+            self.fail("setup_databases/teardown_databases unexpectedly raised "
  277
+                      "an error: %s" % e)
  278
+        finally:
  279
+            db.connections = old_db_connections
  280
+
  281
+
264 282
 class AutoIncrementResetTest(TransactionTestCase):
265 283
     """
266 284
     Here we test creating the same model two times in different test methods,

0 notes on commit 96301d2

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