1
0
mirror of https://github.com/django/django.git synced 2025-07-05 02:09:13 +00:00

r10924@kevin-kubasiks-macbook: kkubasik | 2009-06-25 19:41:10 -0600

[gsoc2009-testing] Working on making runtests.py work in every configuration permutation. Added smarter error messages for missing modules. Currenly having issues with aggregation regression tests.


git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/test-improvements@11111 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Kevin Kubasik 2009-06-26 09:50:32 +00:00
parent 2483e06bd3
commit bbcffeaabe
5 changed files with 101 additions and 74 deletions

View File

@ -68,9 +68,10 @@ class TestServerThread(threading.Thread):
# Must do database stuff in this new thread if database in memory. # Must do database stuff in this new thread if database in memory.
from django.conf import settings from django.conf import settings
if settings.DATABASE_ENGINE == 'sqlite3' \ if settings.DATABASE_ENGINE == 'sqlite3' \
and (not settings.TEST_DATABASE_NAME or settings.TEST_DATABASE_NAME == ':memory:'): and (not settings.TEST_DATABASE_NAME or settings.TEST_DATABASE_NAME == ':memory:'):
from django.db import connection from django.db import connection
db_name = connection.creation.create_test_db(0) db_name = connection.creation.create_test_db(0)
#call_command('syncdb', 0, 0)
# Import the fixture data into the test database. # Import the fixture data into the test database.
if hasattr(self, 'fixtures'): if hasattr(self, 'fixtures'):
# We have to use this slightly awkward syntax due to the fact # We have to use this slightly awkward syntax due to the fact
@ -107,18 +108,22 @@ def stop_test_server(self):
TestCase.start_test_server = classmethod(start_test_server) TestCase.start_test_server = classmethod(start_test_server)
TestCase.stop_test_server = classmethod(stop_test_server) TestCase.stop_test_server = classmethod(stop_test_server)
try:
from windmill.authoring import unit
class WindmillDjangoUnitTest(TestCase, unit.WindmillUnitTestCase):
test_port = 8000
def setUp(self):
self.start_test_server('localhost', self.test_port)
self.test_url = 'http://localhost:%d' % self.server_thread.port
unit.WindmillUnitTestCase.setUp(self)
from windmill.authoring import unit def tearDown(self):
unit.WindmillUnitTestCase.tearDown(self)
self.stop_test_server()
class WindmillDjangoUnitTest(TestCase, unit.WindmillUnitTestCase): WindmillDjangoTransactionUnitTest = WindmillDjangoUnitTest
test_port = 8000
def setUp(self): except Exception, e:
self.start_test_server('localhost', self.test_port) print "You don't appear to have windmill installed, please install before trying to run windmill tests again."
self.test_url = 'http://localhost:%d' % self.server_thread.port
unit.WindmillUnitTestCase.setUp(self)
def tearDown(self):
unit.WindmillUnitTestCase.tearDown(self)
self.stop_test_server()
WindmillDjangoTransactionUnitTest = WindmillDjangoUnitTest

View File

@ -1423,7 +1423,7 @@ class AdminInlineTests(TestCase):
import os import os
from django.test import windmill_tests as djangotest from django.test import windmill_tests as djangotest
#from windmill.authoring import djangotest #from windmill.authoring import djangotest
from windmill.conf import global_settings #from windmill.conf import global_settings
# class TestProjectWindmillTest(djangotest.WindmillDjangoUnitTest): # class TestProjectWindmillTest(djangotest.WindmillDjangoUnitTest):
# fixtures = ['admin-views-users.xml', 'admin-views-colors.xml', 'admin-views-fabrics.xml', 'admin-views-unicode.xml', # fixtures = ['admin-views-users.xml', 'admin-views-colors.xml', 'admin-views-fabrics.xml', 'admin-views-unicode.xml',

View File

@ -3,8 +3,7 @@ from django.contrib import admin
import views import views
import customadmin import customadmin
from django.contrib import admin #admin.autodiscover()
admin.autodiscover()
urlpatterns = patterns('', urlpatterns = patterns('',

View File

@ -1,7 +1,8 @@
# import os # import os
# from django.test import windmill_tests as djangotest # from django.test import windmill_tests as djangotest
# #from windmill.authoring import djangotest # #from windmill.authoring import djangotest
# from windmill.conf import global_settings from windmill.conf import global_settings
ADMIN_URL = "%s/test_admin/admin" % global_settings.TEST_URL
# #
# class TestProjectWindmillTest(djangotest.WindmillDjangoUnitTest): # class TestProjectWindmillTest(djangotest.WindmillDjangoUnitTest):
# fixtures = ['admin-views-users.xml', 'admin-views-colors.xml', 'admin-views-fabrics.xml', 'admin-views-unicode.xml', # fixtures = ['admin-views-users.xml', 'admin-views-colors.xml', 'admin-views-fabrics.xml', 'admin-views-unicode.xml',
@ -16,24 +17,9 @@
# # def test_tryout(self): # # def test_tryout(self):
# # pass # # pass
# #
# Generated by the windmill services transformer
from windmill.authoring import WindmillTestClient from windmill.authoring import WindmillTestClient
# def test_recordingSuite0(): def test_loginAndSetup():
# client = WindmillTestClient(__name__)
# client.open("http://localhost:8000/test_admin/admin")
# client.type(text="Hello", name='q')
# client.click(xpath=u"//span[@id='body']/center/form/table[2]/tbody/tr[8]/td")
# client.waits.forPageLoad(timeout=u'20000')
# client.asserts.assertNode(xpath=u"//div[@id='res']/div/ol/li/h3[1]/a/em")
# client.asserts.assertNode(link=u'How do you say hello in Japanese ? - Yahoo! Answers')
# client.asserts.assertNode(link=u'hello')
# client.asserts.assertNode(link=u'japanese')
#
def test_recordingSuite1():
'''Mostly just a proof of concept to test working order of tests.''' '''Mostly just a proof of concept to test working order of tests.'''
client = WindmillTestClient(__name__) client = WindmillTestClient(__name__)
@ -42,7 +28,10 @@ def test_recordingSuite1():
# print dir(client.commands) # print dir(client.commands)
# print client.commands() # print client.commands()
client.open(url="http://localhost:8000/test_admin/admin") client.open(url=ADMIN_URL)
client.waits.forPageLoad(timeout=u'20000')
client.open(url=ADMIN_URL)
client.waits.forPageLoad(timeout=u'20000')
client.type(text=u'super', id=u'id_username') client.type(text=u'super', id=u'id_username')
client.type(text=u'secret', id=u'id_password') client.type(text=u'secret', id=u'id_password')
client.click(value=u'Log in') client.click(value=u'Log in')
@ -88,12 +77,12 @@ def test_recordingSuite1():
client.click(link=u' Home ') client.click(link=u' Home ')
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
def test_recordingSuite2(): def test_changeListNamingLinkingHistory():
'''Creating a Model with strings for pk, and checking history.''' '''Creating a Model with strings for pk, and checking history.'''
client = WindmillTestClient(__name__) client = WindmillTestClient(__name__)
client.open(url="http://localhost:8000/test_admin/admin") client.open(url=ADMIN_URL)
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
# client.open(url="http://localhost:8000/test_admin/admin") # client.open(url=ADMIN_URL)
# client.type(text=u'super', id=u'id_username') # client.type(text=u'super', id=u'id_username')
# client.type(text=u'secret', id=u'id_password') # client.type(text=u'secret', id=u'id_password')
# client.waits.forPageLoad(timeout=u'20000') # client.waits.forPageLoad(timeout=u'20000')
@ -123,11 +112,11 @@ def test_recordingSuite2():
client.asserts.assertText(xpath=u"//div[@id='changelist']/form/p", validator=u'\n\n1 model with string primary key\n\n\n') client.asserts.assertText(xpath=u"//div[@id='changelist']/form/p", validator=u'\n\n1 model with string primary key\n\n\n')
client.click(link=u' Home ') client.click(link=u' Home ')
def test_recordingSuite3(): def test_filtersSearchOnChangeList():
'''Testing Updates and Filters/Search on Person Models''' '''Testing Updates and Filters/Search on Person Models'''
client = WindmillTestClient(__name__) client = WindmillTestClient(__name__)
client.open(url="http://localhost:8000/test_admin/admin") client.open(url=ADMIN_URL)
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
client.click(link=u'Persons') client.click(link=u'Persons')
client.asserts.assertNode(link=u'John Mauchly') client.asserts.assertNode(link=u'John Mauchly')
@ -170,11 +159,11 @@ def test_recordingSuite3():
client.asserts.assertNode(link=u'Guido van Rossum') client.asserts.assertNode(link=u'Guido van Rossum')
client.click(link=u' Home ') client.click(link=u' Home ')
def test_recordingSuite4(): def test_defaultDeleteAdminAction():
'''Admin Actions test. Test the default delete action.''' '''Admin Actions test. Test the default delete action.'''
client = WindmillTestClient(__name__) client = WindmillTestClient(__name__)
client.open(url="http://localhost:8000/test_admin/admin") client.open(url=ADMIN_URL)
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
client.click(link=u'Fabrics') client.click(link=u'Fabrics')
client.check(name=u'_selected_action') client.check(name=u'_selected_action')
@ -186,10 +175,10 @@ def test_recordingSuite4():
client.asserts.assertNode(link=u'Vertical') client.asserts.assertNode(link=u'Vertical')
client.asserts.assertNode(link=u'Horizontal') client.asserts.assertNode(link=u'Horizontal')
def test_recordingSuite5(): def test_dateTimeModelsandWidgets():
client = WindmillTestClient(__name__) client = WindmillTestClient(__name__)
client.open(url="http://localhost:8000/test_admin/admin") client.open(url=ADMIN_URL)
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
client.click(link=u'Articles') client.click(link=u'Articles')
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
@ -256,10 +245,10 @@ def test_recordingSuite5():
client.click(link=u' Home ') client.click(link=u' Home ')
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
def test_recordingSuite6(): def test_inlineEditandCreate():
client = WindmillTestClient(__name__) client = WindmillTestClient(__name__)
client.open(url="http://localhost:8000/test_admin/admin") client.open(url=ADMIN_URL)
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
client.click(link=u'Parents') client.click(link=u'Parents')
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
@ -282,10 +271,10 @@ def test_recordingSuite6():
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
def test_recordingSuite7(): def test_adminActionEmptyModels():
client = WindmillTestClient(__name__) client = WindmillTestClient(__name__)
client.open(url="http://localhost:8000/test_admin/admin") client.open(url=ADMIN_URL)
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
client.click(link=u'Empty models') client.click(link=u'Empty models')
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
@ -345,10 +334,10 @@ def test_recordingSuite7():
client.click(link=u' Home ') client.click(link=u' Home ')
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
def test_recordingSuite8(): def test_parentChildRelationship():
client = WindmillTestClient(__name__) client = WindmillTestClient(__name__)
client.open(url="http://localhost:8000/test_admin/admin") client.open(url=ADMIN_URL)
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
client.waits.forElement(xpath=u"//div[@id='content-main']/div/table/tbody/tr[21]/td/a", timeout=u'8000') client.waits.forElement(xpath=u"//div[@id='content-main']/div/table/tbody/tr[21]/td/a", timeout=u'8000')
client.click(xpath=u"//div[@id='content-main']/div/table/tbody/tr[21]/td/a") client.click(xpath=u"//div[@id='content-main']/div/table/tbody/tr[21]/td/a")
@ -364,6 +353,8 @@ def test_recordingSuite8():
client.click(value=u'1') client.click(value=u'1')
client.click(name=u'_save') client.click(name=u'_save')
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
client.open(url=ADMIN_URL)
client.waits.forPageLoad(timeout=u'20000')
client.click(link=u'Languages') client.click(link=u'Languages')
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
client.click(link=u' Add language ') client.click(link=u' Add language ')
@ -381,13 +372,13 @@ def test_recordingSuite8():
def test_AdminAuthContrib(): def test_AdminAuthContrib():
client = WindmillTestClient(__name__) client = WindmillTestClient(__name__)
client.open(url="http://localhost:8000/test_admin/admin") client.open(url=ADMIN_URL)
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
client.waits.forElement(link=u'Users', timeout=u'8000') client.waits.forElement(link=u'Users', timeout=u'8000')
client.click(link=u'Users') client.click(link=u'Users')
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
print client.commands.getPageText()
client.asserts.assertNode(link=u'adduser') client.asserts.assertNode(link=u'adduser')
client.asserts.assertNode(link=u'admin')
client.asserts.assertNode(link=u'changeuser') client.asserts.assertNode(link=u'changeuser')
client.asserts.assertNode(link=u'deleteuser') client.asserts.assertNode(link=u'deleteuser')
client.asserts.assertNode(link=u'joepublic') client.asserts.assertNode(link=u'joepublic')
@ -395,13 +386,12 @@ def test_AdminAuthContrib():
client.click(link=u'Yes') client.click(link=u'Yes')
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
client.asserts.assertNode(link=u'adduser') client.asserts.assertNode(link=u'adduser')
client.asserts.assertNode(link=u'admin')
client.asserts.assertNode(link=u'changeuser') client.asserts.assertNode(link=u'changeuser')
client.asserts.assertNode(link=u'deleteuser') client.asserts.assertNode(link=u'deleteuser')
client.asserts.assertNode(link=u'super') # client.asserts.assertNode(link=u'super')
client.click(link=u'6 total') # client.click(link=u'6 total')
client.waits.forPageLoad(timeout=u'20000') # client.waits.forPageLoad(timeout=u'20000')
client.waits.forElement(link=u'super', timeout=u'8000') # client.waits.forElement(link=u'super', timeout=u'8000')
client.click(link=u'super') client.click(link=u'super')
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
client.waits.forElement(link=u'Clear all', timeout=u'8000') client.waits.forElement(link=u'Clear all', timeout=u'8000')
@ -424,9 +414,6 @@ def test_AdminAuthContrib():
client.click(value=u'Search') client.click(value=u'Search')
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
client.asserts.assertNode(link=u'super') client.asserts.assertNode(link=u'super')
client.click(link=u'6 total')
client.waits.forPageLoad(timeout=u'20000')
client.waits.forElement(link=u' Home ', timeout=u'8000')
client.click(link=u' Home ') client.click(link=u' Home ')
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
@ -434,14 +421,17 @@ def test_AdminAuthContrib():
def test_contribFlatSitesRedirect(): def test_contribFlatSitesRedirect():
client = WindmillTestClient(__name__) client = WindmillTestClient(__name__)
client.open(url="http://localhost:8000/test_admin/admin") client.open(url=ADMIN_URL)
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
client.click(xpath=u"//div[@id='content-main']/div[4]/table/tbody/tr[1]/td/a") print client.commands.getPageText()
client.click(xpath=u"//div[@id='content-main']/div[5]/table/tbody/tr[1]/td/a")
client.waits.forPageLoad(timeout=u'20000')
print client.commands.getPageText()
client.click(id=u'id_url') client.click(id=u'id_url')
client.type(text=u'/testflat/test/', id=u'id_url') client.type(text=u'/testflat/test/', id=u'id_url')
client.type(text=u'Test Flat', id=u'id_title') client.type(text=u'Test Flat', id=u'id_title')
client.type(text=u'This is some unique test content.', id=u'id_content') client.type(text=u'This is some unique test content.', id=u'id_content')
client.click(value=u'1') client.select(id='id_sites', val=u'1')
client.click(id=u'fieldsetcollapser1') client.click(id=u'fieldsetcollapser1')
client.check(id=u'id_enable_comments') client.check(id=u'id_enable_comments')
client.click(name=u'_save') client.click(name=u'_save')
@ -454,13 +444,13 @@ def test_contribFlatSitesRedirect():
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
client.click(link=u' Home ') client.click(link=u' Home ')
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
client.click(xpath=u"//div[@id='content-main']/div[6]/table/tbody/tr[1]/th/a") client.click(xpath=u"//div[@id='content-main']/div[table/caption/a/text()='Sites']/table/tbody/tr[1]/th/a")
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
client.click(link=u'example.com') client.click(link=u'example.com')
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
client.click(id=u'id_domain') client.click(id=u'id_domain')
client.doubleClick(id=u'id_domain') client.doubleClick(id=u'id_domain')
client.type(text=u'localhost', id=u'id_domain') client.type(text=u'localhost:8000', id=u'id_domain')
client.click(name=u'_save') client.click(name=u'_save')
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
client.click(link=u' Home ') client.click(link=u' Home ')
@ -471,12 +461,12 @@ def test_contribFlatSitesRedirect():
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
client.click(link=u'View on site') client.click(link=u'View on site')
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
client.asserts.assertText(xpath=u'/html/body', validator=u'This is some unique test content. ') client.asserts.assertText(xpath=u'/html/body', validator=u'\nThis is some unique test content.\n')
client.goBack() client.goBack()
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
client.click(link=u'Home') client.click(link=u'Home')
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
client.click(xpath=u"//div[@id='content-main']/div[5]/table/tbody/tr[1]/th/a") client.click(xpath=u"//div[@id='content-main']/div[6]/table/tbody/tr[1]/th/a")
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')
client.click(link=u' Add redirect ') client.click(link=u' Add redirect ')
client.waits.forPageLoad(timeout=u'20000') client.waits.forPageLoad(timeout=u'20000')

View File

@ -2,16 +2,19 @@
import os, sys, traceback import os, sys, traceback
import unittest import unittest
import coverage
import django.contrib as contrib import django.contrib as contrib
from django.core.servers import basehttp from django.core.servers import basehttp
import django import django
try: try:
set set
except NameError: except NameError:
from sets import Set as set # For Python 2.3 from sets import Set as set # For Python 2.3
try:
import coverage
except Exception, e:
print "coverage module not available"
CONTRIB_DIR_NAME = 'django.contrib' CONTRIB_DIR_NAME = 'django.contrib'
MODEL_TESTS_DIR_NAME = 'modeltests' MODEL_TESTS_DIR_NAME = 'modeltests'
@ -34,6 +37,14 @@ ALWAYS_INSTALLED_APPS = [
'django.contrib.admin', 'django.contrib.admin',
] ]
WINDMILL_FIXTURES = [ 'regressiontests/admin_views/fixtures/%s' % fix for fix in ['admin-views-users.xml',
'admin-views-colors.xml',
'admin-views-fabrics.xml',
'admin-views-unicode.xml',
'multiple-child-classes',
'admin-views-actions.xml',
'string-primary-key.xml',
'admin-views-person.xml']]
#ALWAYS_INSTALLED_APPS.extend(('%s.%s' % (REGRESSION_TESTS_DIR_NAME,a) for a in os.listdir(REGRESSION_TEST_DIR) if not('.py' in a or '.svn' in a) )) #ALWAYS_INSTALLED_APPS.extend(('%s.%s' % (REGRESSION_TESTS_DIR_NAME,a) for a in os.listdir(REGRESSION_TEST_DIR) if not('.py' in a or '.svn' in a) ))
@ -116,6 +127,9 @@ def django_tests(verbosity, interactive, test_labels):
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
#Add the following 2 middleware so we can test them in Windmill.
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
'django.contrib.redirects.middleware.RedirectFallbackMiddleware',
) )
settings.SITE_ID = 1 settings.SITE_ID = 1
# For testing comment-utils, we require the MANAGERS attribute # For testing comment-utils, we require the MANAGERS attribute
@ -127,7 +141,6 @@ def django_tests(verbosity, interactive, test_labels):
# (This import statement is intentionally delayed until after we # (This import statement is intentionally delayed until after we
# access settings because of the USE_I18N dependency.) # access settings because of the USE_I18N dependency.)
from django.db.models.loading import get_apps, load_app from django.db.models.loading import get_apps, load_app
#print settings.INSTALLED_APPS
get_apps() get_apps()
# Load all the test model apps. # Load all the test model apps.
@ -165,16 +178,19 @@ def django_tests(verbosity, interactive, test_labels):
from django.test.utils import get_runner from django.test.utils import get_runner
if not hasattr(settings, 'TEST_RUNNER'): if not hasattr(settings, 'TEST_RUNNER'):
settings.TEST_RUNNER = 'django.test.simple.run_tests' settings.TEST_RUNNER = 'django.test.simple.run_tests'
#establish coverage settings for the regression suite
settings.COVERAGE_MODULE_EXCLUDES = ['modeltests*', 'regressiontests*'] settings.COVERAGE_MODULE_EXCLUDES = ['modeltests*', 'regressiontests*']
settings.COVERAGE_CODE_EXCLUDES = ['def __unicode__\(self\):', 'def get_absolute_url\(self\):'] settings.COVERAGE_CODE_EXCLUDES = ['def __unicode__\(self\):', 'def get_absolute_url\(self\):']
#'from .* import .*', 'import .*', ] #'from .* import .*', 'import .*', ]
settings.COVERAGE_ADDITIONAL_MODULES = ['django'] settings.COVERAGE_ADDITIONAL_MODULES = ['django']
# 'from .* import .*', 'import .*', # 'from .* import .*', 'import .*',
#Run the appropriate test runner based on parameters.
if(do_std): if(do_std):
if(do_coverage): if(do_coverage):
test_runner = get_runner(settings, coverage=True, reports=True) test_runner = get_runner(settings, coverage=True, reports=True)
else: else:
test_runner = get_runner(settings, coverage=False, reports=False) test_runner = get_runner(settings, coverage=False, reports=False)
#Check if this is an old-style testrunner, and behave accordingly.
if(type(test_runner) == 'function'): if(type(test_runner) == 'function'):
failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive, extra_tests=extra_tests) failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive, extra_tests=extra_tests)
else: else:
@ -182,7 +198,7 @@ def django_tests(verbosity, interactive, test_labels):
failures = tr.run_tests(test_labels, verbosity=verbosity, interactive=interactive, extra_tests=extra_tests) failures = tr.run_tests(test_labels, verbosity=verbosity, interactive=interactive, extra_tests=extra_tests)
#from windmill.authoring import djangotest #from windmill.authoring import djangotest
from time import sleep from time import sleep
#Run windmill tests if --windmill parameter was passed.
if do_windmill: if do_windmill:
#from django.test import windmill_tests as djangotest #from django.test import windmill_tests as djangotest
@ -198,14 +214,24 @@ def django_tests(verbosity, interactive, test_labels):
# print cache.app_store # print cache.app_store
# m = cache.app_models['invalid_models'] # m = cache.app_models['invalid_models']
# print m # print m
if(do_std): if do_std:
mod = import_module('.models','modeltests.invalid_models') mod = import_module('.models','modeltests.invalid_models')
try: try:
# print '1'
# print mod
# print '2'
# print cache.app_store
# print '3'
# # print cache.app_models
# print '4'
# print cache.app_models['invalid_models']
if 'invalid_models' in cache.app_models:
del cache.app_models['invalid_models']
del cache.app_store[mod] del cache.app_store[mod]
del cache.app_models['invalid_models']
except Exception, e: except Exception, e:
print e print e
pass
@ -237,9 +263,16 @@ def django_tests(verbosity, interactive, test_labels):
# sys.argv.remove('manage.py') # sys.argv.remove('manage.py')
# if 'test_windmill' in sys.argv: # if 'test_windmill' in sys.argv:
# sys.argv.remove('test_windmill') # sys.argv.remove('test_windmill')
#Load the admin interface
from django.contrib import admin
admin.autodiscover()
#Create the threaded server.
server_container = ServerContainer() server_container = ServerContainer()
server_container.__setattr__('fixtures',[ 'regressiontests/admin_views/fixtures/%s'%fix for fix in ['admin-views-users.xml', 'admin-views-colors.xml', 'admin-views-fabrics.xml', 'admin-views-unicode.xml', #Set the server's 'fixtures' attribute so they can be loaded in-thread if using sqlite's memory backend.
'multiple-child-classes', 'admin-views-actions.xml', 'string-primary-key.xml', 'admin-views-person.xml']]) server_container.__setattr__('fixtures', WINDMILL_FIXTURES )
#Start the server thread.
server_container.start_test_server() server_container.start_test_server()
global_settings.TEST_URL = 'http://localhost:%d' % server_container.server_thread.port global_settings.TEST_URL = 'http://localhost:%d' % server_container.server_thread.port