#19192 closed Bug (fixed)
DjangoTestSuiteRunner cannot run with dummy database backend
Reported by: | Claude Paroz | Owned by: | Jan Bednařík |
---|---|---|---|
Component: | Testing framework | Version: | 1.4 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
(from https://code.djangoproject.com/ticket/18575#comment:9)
To support Django app testing without requiring a database, one can omit the DATABASES setting so as the default dummy backend is configured. Unfortunately, DjangoTestSuiteRunner
does not support this configuration, as it raises ImproperlyConfigured
at the time the connection.creation.create_test_db
is called.
Change History (7)
comment:1 by , 12 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
comment:4 by , 12 years ago
What about providing a dummy database creation class that ignores create_test_db
and destroy_test_db
instead?
-
django/db/backends/dummy/base.py
diff --git a/django/db/backends/dummy/base.py b/django/db/backends/dummy/base.py index 12a940d..b648aae 100644
a b 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 … … class DatabaseWrapper(BaseDatabaseWrapper): 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)
This also allows SimpleTestCase
to work just fine.
comment:5 by , 12 years ago
Yes, Simon's solution is a lot more elegant/pythonic. I will add a test and commit.
comment:6 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Here is patch: https://github.com/django/django/pull/475
Patch skips calling create_test_db and destory_test_db for dummy database backend.
Testing without database (with dummy database backend) works only for SimpleTestCase.
(I added myself into authors because It's my 4th small patch and I did also triaging of few tickets.)