mirror of
https://github.com/django/django.git
synced 2025-07-05 02:09:13 +00:00
r10926@kevin-kubasiks-macbook: kkubasik | 2009-06-26 03:20:06 -0600
[gsoc2009-testing] Confirmed that the command line triggers have the desired effect when combined. Runner is nearing phase 1 feature complete git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/test-improvements@11113 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
2dd363fc0c
commit
a7c8169fda
@ -10,7 +10,7 @@ import os
|
||||
import threading
|
||||
|
||||
__all__ = ('get_apps', 'get_app', 'get_models', 'get_model', 'register_models',
|
||||
'load_app', 'app_cache_ready')
|
||||
'load_app', 'app_cache_ready', 'remove_model')
|
||||
|
||||
class AppCache(object):
|
||||
"""
|
||||
@ -197,6 +197,19 @@ class AppCache(object):
|
||||
finally:
|
||||
self.write_lock.release()
|
||||
|
||||
def remove_model(self, model_name):
|
||||
"""Removes a model from the cache. Used when loading test-only models."""
|
||||
try:
|
||||
self.write_lock.acquire()
|
||||
if model_name in self.app_models:
|
||||
del self.app_models[model_name]
|
||||
except Exception, e:
|
||||
raise e
|
||||
finally:
|
||||
self.write_lock.release()
|
||||
|
||||
|
||||
|
||||
cache = AppCache()
|
||||
|
||||
# These methods were always module level, so are kept that way for backwards
|
||||
@ -209,3 +222,4 @@ get_model = cache.get_model
|
||||
register_models = cache.register_models
|
||||
load_app = cache.load_app
|
||||
app_cache_ready = cache.app_cache_ready
|
||||
remove_model = cache.remove_model
|
@ -5,6 +5,7 @@ from django.core import mail
|
||||
from django.test import signals
|
||||
from django.template import Template
|
||||
from django.utils.translation import deactivate
|
||||
import inspect
|
||||
|
||||
class ContextList(list):
|
||||
"""A wrapper that provides direct key access to context items contained
|
||||
@ -100,3 +101,9 @@ def get_runner(settings, coverage = False, reports = False):
|
||||
test_module = __import__(test_module_name, {}, {}, test_path[-1])
|
||||
test_runner = getattr(test_module, test_path[-1])
|
||||
return test_runner
|
||||
|
||||
def calling_func_name():
|
||||
"""
|
||||
Inspect's on the stack to determine the calling functions name.
|
||||
"""
|
||||
return inspect.stack()[1][3]
|
@ -2,9 +2,9 @@
|
||||
# from django.test import windmill_tests as djangotest
|
||||
# #from windmill.authoring import djangotest
|
||||
|
||||
#from windmill.conf import global_settings
|
||||
#ADMIN_URL = "%s/test_admin/admin" % global_settings.TEST_URL
|
||||
ADMIN_URL = 'http://localhost:8000/test_admin/admin/'
|
||||
from windmill.conf import global_settings
|
||||
ADMIN_URL = "%s/test_admin/admin" % global_settings.TEST_URL
|
||||
#ADMIN_URL = 'http://localhost:8000/test_admin/admin/'
|
||||
|
||||
#
|
||||
# class TestProjectWindmillTest(djangotest.WindmillDjangoUnitTest):
|
||||
@ -21,6 +21,7 @@ ADMIN_URL = 'http://localhost:8000/test_admin/admin/'
|
||||
# # pass
|
||||
#
|
||||
from windmill.authoring import WindmillTestClient
|
||||
#from django.test.windmill_tests import calling_func_name
|
||||
|
||||
def test_loginAndSetup():
|
||||
'''Mostly just a proof of concept to test working order of tests.'''
|
||||
|
@ -183,6 +183,7 @@ def django_tests(verbosity, interactive, test_labels):
|
||||
#'from .* import .*', 'import .*', ]
|
||||
settings.COVERAGE_ADDITIONAL_MODULES = ['django']
|
||||
# 'from .* import .*', 'import .*',
|
||||
failures = 0
|
||||
#Run the appropriate test runner based on parameters.
|
||||
if(do_std):
|
||||
if(do_coverage):
|
||||
@ -206,7 +207,8 @@ def django_tests(verbosity, interactive, test_labels):
|
||||
from windmill.conf import global_settings
|
||||
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.db.models.loading import remove_model
|
||||
remove_model('invalid_models')
|
||||
#from django.utils.importlib import import_module
|
||||
#from django.contrib import admin
|
||||
# print cache.app_models
|
||||
@ -325,12 +327,12 @@ def django_tests(verbosity, interactive, test_labels):
|
||||
from functest import runner
|
||||
runner.CLIRunner.final = classmethod(lambda self, totals: testtotals.update(totals) )
|
||||
import windmill
|
||||
for t in tests:
|
||||
setup_module(t[1])
|
||||
#sys.argv = sys.argv + wmtests
|
||||
sys.argv = wmtests
|
||||
bin.cli()
|
||||
teardown_module(t[1])
|
||||
#for t in tests:
|
||||
setup_module(tests[0][1])
|
||||
#sys.argv = sys.argv + wmtests
|
||||
sys.argv = wmtests
|
||||
bin.cli()
|
||||
teardown_module(tests[0][1])
|
||||
if testtotals['fail'] is not 0:
|
||||
sleep(.5)
|
||||
sys.exit(1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user