mirror of
https://github.com/django/django.git
synced 2025-07-05 10:19:20 +00:00
r10902@kevin-kubasiks-macbook: kkubasik | 2009-06-23 06:51:28 -0600
[gsoc2009-testing] Added method to AppCache to flush cache. Also explicitly remove the modeltests.invalid_models app from the windmill test server, since the invalid models prevent startup git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/test-improvements@11091 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
b6b4a21cf5
commit
fdedd33bd4
@ -178,6 +178,25 @@ class AppCache(object):
|
|||||||
continue
|
continue
|
||||||
model_dict[model_name] = model
|
model_dict[model_name] = model
|
||||||
|
|
||||||
|
def clear_apps(self):
|
||||||
|
"""Clears cache so on next call, it will be reloaded."""
|
||||||
|
self.loaded = False
|
||||||
|
self.write_lock.acquire()
|
||||||
|
self.handled.clear()
|
||||||
|
try:
|
||||||
|
if self.loaded:
|
||||||
|
return
|
||||||
|
for app_name in settings.INSTALLED_APPS:
|
||||||
|
if app_name in self.handled:
|
||||||
|
continue
|
||||||
|
self.load_app(app_name, True)
|
||||||
|
if not self.nesting_level:
|
||||||
|
for app_name in self.postponed:
|
||||||
|
self.load_app(app_name)
|
||||||
|
self.loaded = True
|
||||||
|
finally:
|
||||||
|
self.write_lock.release()
|
||||||
|
|
||||||
cache = AppCache()
|
cache = AppCache()
|
||||||
|
|
||||||
# These methods were always module level, so are kept that way for backwards
|
# These methods were always module level, so are kept that way for backwards
|
||||||
|
@ -35,7 +35,7 @@ ALWAYS_INSTALLED_APPS = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
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) ))
|
||||||
|
|
||||||
def get_test_models():
|
def get_test_models():
|
||||||
models = []
|
models = []
|
||||||
@ -127,6 +127,7 @@ 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.
|
||||||
@ -174,21 +175,36 @@ 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
|
||||||
|
|
||||||
if do_windmill:
|
if do_windmill:
|
||||||
|
|
||||||
#from django.test import windmill_tests as djangotest
|
#from django.test import windmill_tests as djangotest
|
||||||
import types
|
import types
|
||||||
import logging
|
import logging
|
||||||
from windmill.conf import global_settings
|
from windmill.conf import global_settings
|
||||||
from django.test.windmill_tests import WindmillDjangoUnitTest
|
|
||||||
from django.core.management.commands.test_windmill import ServerContainer, attempt_import
|
from django.core.management.commands.test_windmill import ServerContainer, attempt_import
|
||||||
|
from django.test.windmill_tests import WindmillDjangoUnitTest
|
||||||
|
from django.db.models.loading import cache
|
||||||
|
from django.utils.importlib import import_module
|
||||||
|
|
||||||
|
# print cache.app_models
|
||||||
|
# print cache.app_store
|
||||||
|
# m = cache.app_models['invalid_models']
|
||||||
|
# print m
|
||||||
|
mod = import_module('.models','modeltests.invalid_models')
|
||||||
|
del cache.app_store[mod]
|
||||||
|
del cache.app_models['invalid_models']
|
||||||
|
|
||||||
|
|
||||||
|
# print cache.app_models
|
||||||
|
# print cache.app_store
|
||||||
#from django.test import windmill_tests
|
#from django.test import windmill_tests
|
||||||
# as testwm_cmd
|
# as testwm_cmd
|
||||||
# windmill_runner = testwm_cmd()
|
# windmill_runner = testwm_cmd()
|
||||||
# windmill_runner.handle()
|
# windmill_runner.handle()
|
||||||
|
|
||||||
|
|
||||||
|
#settings.INSTALLED_APPS = [ia for ia in settings.INSTALLED_APPS if True]
|
||||||
# from windmill.authoring.djangotest import WindmillDjangoUnitTest
|
# from windmill.authoring.djangotest import WindmillDjangoUnitTest
|
||||||
# if 'ie' in labels:
|
# if 'ie' in labels:
|
||||||
# global_settings.START_IE = True
|
# global_settings.START_IE = True
|
||||||
@ -209,19 +225,19 @@ def django_tests(verbosity, interactive, test_labels):
|
|||||||
# if 'test_windmill' in sys.argv:
|
# if 'test_windmill' in sys.argv:
|
||||||
# sys.argv.remove('test_windmill')
|
# sys.argv.remove('test_windmill')
|
||||||
server_container = ServerContainer()
|
server_container = ServerContainer()
|
||||||
server_container.fixtures = ['admin-views-users.xml', 'admin-views-colors.xml', 'admin-views-fabrics.xml', 'admin-views-unicode.xml',
|
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',
|
||||||
'multiple-child-classes', 'admin-views-actions.xml', 'string-primary-key.xml', 'admin-views-person.xml']
|
'multiple-child-classes', 'admin-views-actions.xml', 'string-primary-key.xml', 'admin-views-person.xml']])
|
||||||
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
|
||||||
|
|
||||||
# import windmill
|
import windmill
|
||||||
# windmill.stdout, windmill.stdin = sys.stdout, sys.stdin
|
# windmill.stdout, windmill.stdin = sys.stdout, sys.stdin
|
||||||
from windmill.authoring import setup_module, teardown_module
|
from windmill.authoring import setup_module, teardown_module
|
||||||
|
|
||||||
# from django.conf import settings
|
# from django.conf import settings
|
||||||
tests = []
|
tests = []
|
||||||
for name in [ app for app in settings.INSTALLED_APPS if not('invalid_models' in app)]:
|
for name in [ app for app in settings.INSTALLED_APPS if not('invalid' in app)]:
|
||||||
for suffix in ['tests', 'wmtests', 'windmilltests']:
|
for suffix in ['tests', 'wmtests', 'windmilltests']:
|
||||||
x = attempt_import(name, suffix)
|
x = attempt_import(name, suffix)
|
||||||
if x is not None: tests.append((suffix,x,));
|
if x is not None: tests.append((suffix,x,));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user