Opened 8 years ago

Closed 8 years ago

#13367 closed (wontfix)

django/test/ Imports django.db even when your app dosn't use a db

Reported by: Damian Zaremba Owned by: nobody
Component: Testing framework Version: 1.1
Severity: Keywords: django.db, db, testing
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Even if your app requires no database interaction the testing module still imports django.db. To get around this you have to do stupid things like create an sqllite db in memory. This shouldn't be required as if your app doesn't need a db you shouldn't have to configure one and the testing framework shouldn't test it (or there should be a way to ignore it).

Change History (1)

comment:1 Changed 8 years ago by Russell Keith-Magee

Resolution: wontfix
Status: newclosed

It's not just the import that is a problem. The simple test runner constructs and destroys a test database.

If you don't want to use a database at all, you can define a custom test runner; in 1.2, this looks something like:

from django.test.simple import DjangoTestSuiteRunner

class MyRunner(DjangoTestSuiteRunner):
    def setup_databases(self, **kwargs):
    def teardown_databases(self, old_config, **kwargs):

Then, put TEST_RUNNER = '' in your

There is an analogous approach in 1.1, but it involves copying django.test.simple.run_tests() and removing the database setup lines.

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