summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Kubasik <kevin@kubasik.net>2009-06-26 09:52:22 +0000
committerKevin Kubasik <kevin@kubasik.net>2009-06-26 09:52:22 +0000
commita7c8169fda81f00434e6bc1a3a34f32e06054748 (patch)
tree61ce3c1283a7222ace7a9d2fe8c8d0b7336d0a38
parent2dd363fc0c608556edf852552434591a7d519bc7 (diff)
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
-rw-r--r--django/db/models/loading.py16
-rw-r--r--django/test/utils.py7
-rw-r--r--tests/regressiontests/admin_views/windmilltests/__init__.py9
-rwxr-xr-xtests/runtests.py16
4 files changed, 36 insertions, 12 deletions
diff --git a/django/db/models/loading.py b/django/db/models/loading.py
index 009e695711..fa6e911d12 100644
--- a/django/db/models/loading.py
+++ b/django/db/models/loading.py
@@ -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 \ No newline at end of file
diff --git a/django/test/utils.py b/django/test/utils.py
index 5d6686f210..8430ef8f10 100644
--- a/django/test/utils.py
+++ b/django/test/utils.py
@@ -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] \ No newline at end of file
diff --git a/tests/regressiontests/admin_views/windmilltests/__init__.py b/tests/regressiontests/admin_views/windmilltests/__init__.py
index 8fa8dcac92..05bddd2a27 100644
--- a/tests/regressiontests/admin_views/windmilltests/__init__.py
+++ b/tests/regressiontests/admin_views/windmilltests/__init__.py
@@ -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.'''
@@ -494,4 +495,4 @@ def test_contribFlatSitesRedirect():
client.waits.forPageLoad(timeout=u'8000')
client.asserts.assertText(xpath=u'/html/body', validator=u'\nThis is some unique test content.\n')
client.open(url=u'http://localhost:8000/test_admin/admin/')
- client.waits.forPageLoad(timeout=u'8000') \ No newline at end of file
+ client.waits.forPageLoad(timeout=u'8000')
diff --git a/tests/runtests.py b/tests/runtests.py
index 0048f25f39..e12a5e2581 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -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)