Opened 15 years ago

Closed 15 years ago

#13367 closed (wontfix)

django/test/simple.py 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: no UI/UX: no

Description

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 by Russell Keith-Magee, 15 years ago

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):
        pass
    def teardown_databases(self, old_config, **kwargs):
        pass

Then, put TEST_RUNNER = 'path.to.runner.MyRunner' in your settings.py.

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