Author: kkubasik
Date: 2009-07-01 05:39:52 -0500 (Wed, 01 Jul 2009)
New Revision: 11140

Modified:
   django/branches/soc2009/test-improvements/
   
django/branches/soc2009/test-improvements/django/core/management/commands/test_windmill.py
   django/branches/soc2009/test-improvements/django/test/test_coverage.py
   django/branches/soc2009/test-improvements/tests/runtests.py
Log:
[gsoc2009-testing] Import windmill imports before starting coverage, this fixes 
some module load issues



Property changes on: django/branches/soc2009/test-improvements
___________________________________________________________________
Name: svk:merge
   - 23ef3597-c209-482b-90c0-ea6045f15f7f:/local/django-gsoc:10960
23ef3597-c209-482b-90c0-ea6045f15f7f:/local/django/trunk:10927
bcc190cf-cafb-0310-a4f2-bffc1f526a37:/django/trunk:1054
   + 23ef3597-c209-482b-90c0-ea6045f15f7f:/local/django-gsoc:10961
23ef3597-c209-482b-90c0-ea6045f15f7f:/local/django/trunk:10927
bcc190cf-cafb-0310-a4f2-bffc1f526a37:/django/trunk:1054

Modified: 
django/branches/soc2009/test-improvements/django/core/management/commands/test_windmill.py
===================================================================
--- 
django/branches/soc2009/test-improvements/django/core/management/commands/test_windmill.py
  2009-07-01 10:39:40 UTC (rev 11139)
+++ 
django/branches/soc2009/test-improvements/django/core/management/commands/test_windmill.py
  2009-07-01 10:39:52 UTC (rev 11140)
@@ -1,12 +1,13 @@
 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

Modified: django/branches/soc2009/test-improvements/django/test/test_coverage.py
===================================================================
--- django/branches/soc2009/test-improvements/django/test/test_coverage.py      
2009-07-01 10:39:40 UTC (rev 11139)
+++ django/branches/soc2009/test-improvements/django/test/test_coverage.py      
2009-07-01 10:39:52 UTC (rev 11140)
@@ -3,7 +3,7 @@
 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
 
@@ -34,7 +34,7 @@
         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', []):
@@ -124,42 +124,3 @@
 
         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)

Modified: django/branches/soc2009/test-improvements/tests/runtests.py
===================================================================
--- django/branches/soc2009/test-improvements/tests/runtests.py 2009-07-01 
10:39:40 UTC (rev 11139)
+++ django/branches/soc2009/test-improvements/tests/runtests.py 2009-07-01 
10:39:52 UTC (rev 11140)
@@ -185,10 +185,19 @@
 
     # 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)
@@ -201,17 +210,6 @@
 
     #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')
 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to