﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
6515	Django test framework requires a database	Joe Shaw <jshaw@…>	nobody	"We're using Django without a database (and hence no models).  We're using only views, because our web application is essentially an XML-RPC client to another server which actually contains all the data.

We'd still like to be able to use the Django's integration into unittest to test our views using django.test.client, but evidently we're required to have a database:

{{{
>>> from django.core.management import execute_manager
>>> from servweb import settings
>>> execute_manager(settings, [""manage.py"", ""test""])
Creating test database...
Traceback (most recent call last):
  File ""<stdin>"", line 1, in ?
  File ""/ita/src/django/django/core/management/__init__.py"", line 272, in execute_manager
    utility.execute()
  File ""/ita/src/django/django/core/management/__init__.py"", line 219, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File ""/ita/src/django/django/core/management/base.py"", line 72, in run_from_argv
    self.execute(*args, **options.__dict__)
  File ""/ita/src/django/django/core/management/base.py"", line 86, in execute
    output = self.handle(*args, **options)
  File ""django/core/management/commands/test.py"", line 34, in handle
    failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive)
  File ""django/test/simple.py"", line 142, in run_tests
    create_test_db(verbosity, autoclobber=not interactive)
  File ""django/test/utils.py"", line 152, in create_test_db
    cursor = connection.cursor()
  File ""/ita/src/django/django/db/backends/dummy/base.py"", line 14, in complain
    raise ImproperlyConfigured, ""You haven't set the DATABASE_ENGINE setting yet.""
django.core.exceptions.ImproperlyConfigured: You haven't set the DATABASE_ENGINE setting yet.
}}}

(Indeed, servweb.settings does not have DATABASE_ENGINE.)

We can get partial support by running the client code by hand.  That is, manually setting DJANGO_SETTINGS_MODULE, importing django.test.client, and calling things like Client.get() gives us some but not all the information we'd like:

{{{
>>> r = c.get(""/"")
>>> print r.__dict__
{'cookies': <SimpleCookie: >, 'context': None, '_is_string': True, '_charset': 'utf-8', 
'headers': {'Content-Type': 'text/html; charset=utf-8'}, 'template': None, 'status_code': 200, '_container': [...]}
}}}

Notably, context and template are both None -- neither of them should be.

We're using 0.96.1, but I've verified this is still the case in SVN as of 2007-12-17.  If you think this has been fixed more recently (a) sorry! and (b) I can update and test."		closed	Testing framework	dev		wontfix			Unreviewed	0	0	0	0	0	0
