Commits

Anonymous committed c1c8f60

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

  • Participants
  • Parent commits 9fc4e0d
  • Branches soc2009/test-improvements

Comments (0)

Files changed (4)

File django/db/models/loading.py

 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):
     """
         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
 register_models = cache.register_models
 load_app = cache.load_app
 app_cache_ready = cache.app_cache_ready
+remove_model = cache.remove_model

File django/test/utils.py

 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
     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]

File tests/regressiontests/admin_views/windmilltests/__init__.py

 # 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):
 #     #     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.'''
     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')
+    client.waits.forPageLoad(timeout=u'8000')

File tests/runtests.py

     #'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):
         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
             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)