Fixed #2916 -- Moved syncdb call out of simple test runner and into create_test_db, to match documentation and simplify testing process for people using other test frameworks. Thanks, remco@diji.biz.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4541 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
895633a80d
commit
fb509ee8d3
1
AUTHORS
1
AUTHORS
|
@ -154,6 +154,7 @@ answer newbie questions, and generally made Django that much better:
|
||||||
Michael Radziej <mir@noris.de>
|
Michael Radziej <mir@noris.de>
|
||||||
ramiro
|
ramiro
|
||||||
Brian Ray <http://brianray.chipy.org/>
|
Brian Ray <http://brianray.chipy.org/>
|
||||||
|
remco@diji.biz
|
||||||
rhettg@gmail.com
|
rhettg@gmail.com
|
||||||
Oliver Rutherfurd <http://rutherfurd.net/>
|
Oliver Rutherfurd <http://rutherfurd.net/>
|
||||||
Ivan Sagalaev (Maniac) <http://www.softwaremaniacs.org/>
|
Ivan Sagalaev (Maniac) <http://www.softwaremaniacs.org/>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import unittest, doctest
|
import unittest, doctest
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core import management
|
|
||||||
from django.test.utils import setup_test_environment, teardown_test_environment
|
from django.test.utils import setup_test_environment, teardown_test_environment
|
||||||
from django.test.utils import create_test_db, destroy_test_db
|
from django.test.utils import create_test_db, destroy_test_db
|
||||||
from django.test.testcases import OutputChecker, DocTestRunner
|
from django.test.testcases import OutputChecker, DocTestRunner
|
||||||
|
@ -78,7 +77,6 @@ def run_tests(module_list, verbosity=1, extra_tests=[]):
|
||||||
|
|
||||||
old_name = settings.DATABASE_NAME
|
old_name = settings.DATABASE_NAME
|
||||||
create_test_db(verbosity)
|
create_test_db(verbosity)
|
||||||
management.syncdb(verbosity, interactive=False)
|
|
||||||
unittest.TextTestRunner(verbosity=verbosity).run(suite)
|
unittest.TextTestRunner(verbosity=verbosity).run(suite)
|
||||||
destroy_test_db(old_name, verbosity)
|
destroy_test_db(old_name, verbosity)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import sys, time
|
import sys, time
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import connection, transaction, backend
|
from django.db import connection, transaction, backend
|
||||||
|
from django.core import management
|
||||||
from django.dispatch import dispatcher
|
from django.dispatch import dispatcher
|
||||||
from django.test import signals
|
from django.test import signals
|
||||||
from django.template import Template
|
from django.template import Template
|
||||||
|
@ -84,6 +85,8 @@ def create_test_db(verbosity=1, autoclobber=False):
|
||||||
connection.close()
|
connection.close()
|
||||||
settings.DATABASE_NAME = TEST_DATABASE_NAME
|
settings.DATABASE_NAME = TEST_DATABASE_NAME
|
||||||
|
|
||||||
|
management.syncdb(verbosity, interactive=False)
|
||||||
|
|
||||||
# Get a cursor (even though we don't need one yet). This has
|
# Get a cursor (even though we don't need one yet). This has
|
||||||
# the side effect of initializing the test database.
|
# the side effect of initializing the test database.
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
|
Loading…
Reference in New Issue