Author: kkubasik
Date: 2009-06-16 20:27:31 -0500 (Tue, 16 Jun 2009)
New Revision: 11017
Modified:
django/branches/soc2009/test-improvements/tests/runtests.py
Log:
[gsoc2009-testing] reworking runtests.py so its custom runtime environment
doesn't interfear with the test_windmill environment
Modified: django/branches/soc2009/test-improvements/tests/runtests.py
===================================================================
--- django/branches/soc2009/test-improvements/tests/runtests.py 2009-06-17
01:27:25 UTC (rev 11016)
+++ django/branches/soc2009/test-improvements/tests/runtests.py 2009-06-17
01:27:31 UTC (rev 11017)
@@ -165,12 +165,83 @@
test_runner = get_runner(settings, coverage=True, reports=True)
tr = test_runner()
failures = tr.run_tests(test_labels, verbosity=verbosity,
interactive=interactive, extra_tests=extra_tests)
- if failures:
- sys.exit(failures)
- from django.core.management.commands.test_windmill import Command as
testwm_cmd
- windmill_runner = testwm_cmd()
- windmill_runner.handle()
+ from django.core.management.commands.test_windmill import ServerContainer,
attempt_import
+ # as testwm_cmd
+ # windmill_runner = testwm_cmd()
+ # 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.
settings.INSTALLED_APPS = old_installed_apps
settings.ROOT_URLCONF = old_root_urlconf
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---