Commits

Anonymous committed b54a87f

[gsoc2009-testing] Import windmill imports before starting coverage, this fixes some module load issues

Comments (0)

Files changed (3)

django/core/management/commands/test_windmill.py

 from django.core.management.base import BaseCommand
 #from windmill.authoring import djangotest
-from  django.test import windmill_tests as djangotest
+from django.utils import importlib
+from django.test import windmill_tests as djangotest
 import sys, os
 from time import sleep
 import types
 import logging
 import threading
-from django.utils import importlib
+
 class ServerContainer(object):
     start_test_server = djangotest.start_test_server
     stop_test_server = djangotest.stop_test_server

django/test/test_coverage.py

 import os, sys
 
 from django.conf import settings
-from django.db.models import get_app, get_apps
+from django.db.models.loading import get_app, get_apps
 
 from django.test.simple import DefaultTestRunner as base_run_tests
 
         Runs the specified tests while generating code coverage statistics. Upon
         the tests' completion, the results are printed to stdout.
         """
-        self.cov.erase()
+        #self.cov.erase()
         #Allow an on-disk cache of coverage stats.
         self.cov.use_cache(0)
         #for e in getattr(settings, 'COVERAGE_CODE_EXCLUDES', []):
 
         return res
 
-
-try:
-    set
-except:
-    from sets import Set as set
-
-
-class ModuleVars(object):
-    modules = dict()
-    def __new__(cls, module_name, module=None):
-        if cls.modules.get(module_name, None):
-            return cls.modules.get(module_name)
-        else:
-            obj=super(ModuleVars, cls).__new__(cls)
-            obj._init(module_name, module)
-            cls.modules[module_name] = obj
-            return obj
-
-    def _init(self, module_name, module):
-        source_file, stmts, excluded, missed, missed_display = coverage.analysis2(module)
-        executed = list(set(stmts).difference(missed))
-        total = list(set(stmts).union(excluded))
-        total.sort()
-        title = module.__name__
-        total_count = len(total)
-        executed_count = len(executed)
-        excluded_count = len(excluded)
-        missed_count = len(missed)
-        try:
-            percent_covered = float(len(executed))/len(stmts)*100
-        except ZeroDivisionError:
-            percent_covered = 100
-        test_timestamp = time.strftime('%a %Y-%m-%d %H:%M %Z')
-        severity = 'normal'
-        if percent_covered < 75: severity = 'warning'
-        if percent_covered < 50: severity = 'critical'
-
-        for k, v in locals().iteritems():
-            setattr(self, k, v)

tests/runtests.py

 
     # Default number of failures is 0
     failures = 0
-
+    if do_windmill:
+        # Our bank of windmill-specific imports. Only loaded when used.
+        import types
+        import logging
+        import threading
+        from windmill.conf import global_settings
+        from windmill.authoring import setup_module, teardown_module
+        from django.core.management.commands.test_windmill import ServerContainer, attempt_import
+        from django.test.windmill_tests import WindmillDjangoUnitTest
+        from django.db.models.loading import remove_model
     #Run the appropriate test runner based on command line params.
-    if(do_std):
-        if(do_coverage):
+    if do_std:
+        if do_coverage:
             test_runner = get_runner(settings, coverage=True, reports=True)
         else:
             test_runner = get_runner(settings, coverage=False, reports=False)
 
     #Run windmill tests if --windmill parameter was passed.
     if do_windmill:
-        # Our bank of windmill-specific imports. Only loaded when used.
-        import types
-        import logging
-        import threading
-        from windmill.conf import global_settings
-        from windmill.authoring import setup_module, teardown_module
-        from django.core.management.commands.test_windmill import ServerContainer, attempt_import
-        from django.test.windmill_tests import WindmillDjangoUnitTest
-        from django.db.models.loading import remove_model
-
-
         # We don't want to try and parse models that we know are invalid.
         remove_model('invalid_models')