mirror of
https://github.com/django/django.git
synced 2025-07-06 10:49:17 +00:00
[gsoc2009-testing] reworking runtests.py so its custom runtime environment doesn't interfear with the test_windmill environment
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/test-improvements@11017 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
2a2f711d38
commit
9e685499ff
@ -165,12 +165,83 @@ def django_tests(verbosity, interactive, test_labels):
|
|||||||
test_runner = get_runner(settings, coverage=True, reports=True)
|
test_runner = get_runner(settings, coverage=True, reports=True)
|
||||||
tr = test_runner()
|
tr = test_runner()
|
||||||
failures = tr.run_tests(test_labels, verbosity=verbosity, interactive=interactive, extra_tests=extra_tests)
|
failures = tr.run_tests(test_labels, verbosity=verbosity, interactive=interactive, extra_tests=extra_tests)
|
||||||
if failures:
|
from django.core.management.commands.test_windmill import ServerContainer, attempt_import
|
||||||
sys.exit(failures)
|
# as testwm_cmd
|
||||||
from django.core.management.commands.test_windmill import Command as testwm_cmd
|
# windmill_runner = testwm_cmd()
|
||||||
windmill_runner = testwm_cmd()
|
# windmill_runner.handle()
|
||||||
windmill_runner.handle()
|
|
||||||
|
|
||||||
|
from windmill.conf import global_settings
|
||||||
|
from windmill.authoring.djangotest import WindmillDjangoUnitTest
|
||||||
|
# if 'ie' in labels:
|
||||||
|
# global_settings.START_IE = True
|
||||||
|
# sys.argv.remove('ie')
|
||||||
|
# elif 'safari' in labels:
|
||||||
|
# global_settings.START_SAFARI = True
|
||||||
|
# sys.argv.remove('safari')
|
||||||
|
# elif 'chrome' in labels:
|
||||||
|
# global_settings.START_CHROME = True
|
||||||
|
# sys.argv.remove('chrome')
|
||||||
|
# else:
|
||||||
|
global_settings.START_FIREFOX = True
|
||||||
|
# if 'firefox' in labels:
|
||||||
|
# sys.argv.remove('firefox')
|
||||||
|
|
||||||
|
# if 'manage.py' in sys.argv:
|
||||||
|
# sys.argv.remove('manage.py')
|
||||||
|
# if 'test_windmill' in sys.argv:
|
||||||
|
# sys.argv.remove('test_windmill')
|
||||||
|
server_container = ServerContainer()
|
||||||
|
server_container.start_test_server()
|
||||||
|
|
||||||
|
global_settings.TEST_URL = 'http://localhost:%d' % server_container.server_thread.port
|
||||||
|
|
||||||
|
# import windmill
|
||||||
|
# windmill.stdout, windmill.stdin = sys.stdout, sys.stdin
|
||||||
|
from windmill.authoring import setup_module, teardown_module
|
||||||
|
|
||||||
|
# from django.conf import settings
|
||||||
|
tests = []
|
||||||
|
for name in settings.INSTALLED_APPS:
|
||||||
|
for suffix in ['tests', 'wmtests', 'windmilltests']:
|
||||||
|
x = attempt_import(name, suffix)
|
||||||
|
if x is not None: tests.append((suffix,x,));
|
||||||
|
|
||||||
|
wmtests = []
|
||||||
|
for (ttype, mod,) in tests:
|
||||||
|
if ttype == 'tests':
|
||||||
|
for ucls in [getattr(mod, x) for x in dir(mod)
|
||||||
|
if ( type(getattr(mod, x, None)) in (types.ClassType,
|
||||||
|
types.TypeType) ) and
|
||||||
|
issubclass(getattr(mod, x), WindmillDjangoUnitTest)
|
||||||
|
]:
|
||||||
|
wmtests.append(ucls.test_dir)
|
||||||
|
|
||||||
|
else:
|
||||||
|
if mod.__file__.endswith('__init__.py') or mod.__file__.endswith('__init__.pyc'):
|
||||||
|
wmtests.append(os.path.join(*os.path.split(os.path.abspath(mod.__file__))[:-1]))
|
||||||
|
else:
|
||||||
|
wmtests.append(os.path.abspath(mod.__file__))
|
||||||
|
|
||||||
|
if len(wmtests) is 0:
|
||||||
|
print 'Sorry, no windmill tests found.'
|
||||||
|
else:
|
||||||
|
testtotals = {}
|
||||||
|
x = logging.getLogger()
|
||||||
|
x.setLevel(0)
|
||||||
|
from windmill.server.proxy import logger
|
||||||
|
from functest import bin
|
||||||
|
from functest import runner
|
||||||
|
runner.CLIRunner.final = classmethod(lambda self, totals: testtotals.update(totals) )
|
||||||
|
import windmill
|
||||||
|
setup_module(tests[0][1])
|
||||||
|
sys.argv = sys.argv + wmtests
|
||||||
|
bin.cli()
|
||||||
|
teardown_module(tests[0][1])
|
||||||
|
# if testtotals['fail'] is not 0:
|
||||||
|
# sleep(.5)
|
||||||
|
# sys.exit(1)
|
||||||
|
if failures or testtotals['fail'] is not 0:
|
||||||
|
sys.exit(failures + testtotals['fail'])
|
||||||
# Restore the old settings.
|
# Restore the old settings.
|
||||||
settings.INSTALLED_APPS = old_installed_apps
|
settings.INSTALLED_APPS = old_installed_apps
|
||||||
settings.ROOT_URLCONF = old_root_urlconf
|
settings.ROOT_URLCONF = old_root_urlconf
|
||||||
|
Loading…
x
Reference in New Issue
Block a user