Code

Opened 4 years ago

Closed 4 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: UI/UX:

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

Attachments (0)

Change History (1)

comment:1 Changed 4 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.