mirror of
https://github.com/django/django.git
synced 2025-07-05 02:09:13 +00:00
[gsoc2009-testing] Import windmill imports before starting coverage, this fixes some module load issues
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/test-improvements@11140 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
1ed1ac22fe
commit
b5ea9f6ad5
@ -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
|
||||
|
@ -3,7 +3,7 @@ import coverage, time
|
||||
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 @@ class BaseCoverageRunner(object):
|
||||
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 @@ class ReportingCoverageRunner(BaseCoverageRunner):
|
||||
|
||||
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)
|
||||
|
@ -185,10 +185,19 @@ def django_tests(verbosity, interactive, test_labels):
|
||||
|
||||
# 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 @@ def django_tests(verbosity, interactive, test_labels):
|
||||
|
||||
#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')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user