Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#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 Jan Bednařík, 12 years ago

Has patch: set
Owner: changed from nobody to Jan Bednařík

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.)

comment:2 by Jan Bednařík, 12 years ago

I made a mistake in patch...

comment:3 by Jan Bednařík, 12 years ago

Patch and pull request has been updated, ready for review.

comment:4 by Simon Charette, 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):  
    3131class DatabaseClient(BaseDatabaseClient):
    3232    runshell = complain
    3333
     34class DatabaseCreation(BaseDatabaseCreation):
     35    create_test_db = ignore
     36    destroy_test_db = ignore
     37
    3438class DatabaseIntrospection(BaseDatabaseIntrospection):
    3539    get_table_list = complain
    3640    get_table_description = complain
    class DatabaseWrapper(BaseDatabaseWrapper):  
    6468        self.features = BaseDatabaseFeatures(self)
    6569        self.ops = DatabaseOperations(self)
    6670        self.client = DatabaseClient(self)
    67         self.creation = BaseDatabaseCreation(self)
     71        self.creation = DatabaseCreation(self)
    6872        self.introspection = DatabaseIntrospection(self)
    6973        self.validation = BaseDatabaseValidation(self)

This also allows SimpleTestCase to work just fine.

comment:5 by Claude Paroz, 12 years ago

Yes, Simon's solution is a lot more elegant/pythonic. I will add a test and commit.

comment:6 by Claude Paroz <claude@…>, 12 years ago

Resolution: fixed
Status: newclosed

In b740da3504ea3b9c841f5a9eb14191a0b5410565:

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.

comment:7 by Claude Paroz <claude@…>, 12 years ago

In 96301d21bb2ec7c5e06e3cea54fa2cdcd25a464d:

[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 b740da3504 from master.

Note: See TracTickets for help on using tickets.
Back to Top