From 772452ccc7148a2e459148b18c96ff443a068693 Mon Sep 17 00:00:00 2001 From: Kevin Kubasik Date: Wed, 1 Jul 2009 22:27:02 +0000 Subject: [PATCH] [gsoc2009-testing] Cleanup threads after tests run. Ensure the django admin is populated before windmill tests start git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/test-improvements@11145 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/test/windmill_tests.py | 24 +++++++++++----------- tests/regressiontests/admin_views/tests.py | 4 ++-- tests/runtests.py | 4 +++- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/django/test/windmill_tests.py b/django/test/windmill_tests.py index 8d25e5afca..3212e9c1e8 100644 --- a/django/test/windmill_tests.py +++ b/django/test/windmill_tests.py @@ -55,18 +55,18 @@ class TestServerThread(threading.Thread): # Must do database stuff in this new thread if database in memory. from django.conf import settings - if settings.DATABASE_ENGINE == 'sqlite3' \ - and (not settings.TEST_DATABASE_NAME or settings.TEST_DATABASE_NAME == ':memory:'): - from django.db import connection - print 'Creating test DB' - db_name = connection.creation.create_test_db(0) - #call_command('syncdb', 0, 0) - # Import the fixture data into the test database. - if hasattr(self, 'fixtures'): - print 'Loading fixtures.' - # We have to use this slightly awkward syntax due to the fact - # that we're using *args and **kwargs together. - call_command('loaddata', *self.fixtures, **{'verbosity': 0}) + #if settings.DATABASE_ENGINE == 'sqlite3' \ + # and (not settings.TEST_DATABASE_NAME or settings.TEST_DATABASE_NAME == ':memory:'): + from django.db import connection + print 'Creating test DB' + db_name = connection.creation.create_test_db(0,autoclobber=True) + #call_command('syncdb', 0, 0) + # Import the fixture data into the test database. + if hasattr(self, 'fixtures'): + print 'Loading fixtures.' + # We have to use this slightly awkward syntax due to the fact + # that we're using *args and **kwargs together. + call_command('loaddata', *self.fixtures, **{'verbosity': 0}) try: print "running thread" diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py index 9cf6a0a944..2f923182de 100644 --- a/tests/regressiontests/admin_views/tests.py +++ b/tests/regressiontests/admin_views/tests.py @@ -35,12 +35,12 @@ class AdminViewBasicTest(TestCase): def setUp(self): from django.contrib import admin - admin.autodiscover() + admin.register(TestSection) self.client.login(username='super', password='secret') def tearDown(self): from django.contrib import admin - admin.autodiscover() + admin.unregister(TestSection) self.client.logout() def testTrailingSlashRequired(self): diff --git a/tests/runtests.py b/tests/runtests.py index 463a1492b4..247f684e06 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -274,7 +274,8 @@ def django_tests(verbosity, interactive, test_labels): print 'Waiting for threaded server to come online.' started.wait() print 'DB Ready, Server online.' - + from django.contrib import admin + admin.autodiscover() # Set the testing URL based on what available port we get. @@ -331,6 +332,7 @@ def django_tests(verbosity, interactive, test_labels): #count = count + 1 #setup_module(tests[count][1]) teardown_module(tests[0][1]) + server_container.stop_test_server() # sys.argv = [wmtests[0],] # bin.cli()