Skip to content

Instantly share code, notes, and snippets.

@y-ogi
Created July 28, 2011 01:07
Show Gist options
  • Save y-ogi/1110715 to your computer and use it in GitHub Desktop.
Save y-ogi/1110715 to your computer and use it in GitHub Desktop.
XML test runner for kay
# -*- coding: utf-8 -*-
#
#
#
import os
import logging
import unittest
import xmlrunner
from werkzeug.utils import import_string
from kay.management.test import setup_env, setup_stub
from kay.conf import settings
def runtest(target='', verbosity=0):
suite = unittest.TestSuite()
if target:
tests_mod = import_string("%s.tests" % target)
suite.addTest(unittest.defaultTestLoader.loadTestsFromModule(
tests_mod))
else:
for app_name in settings.INSTALLED_APPS:
if app_name.startswith('kay.'):
continue
try:
tests_mod = import_string("%s.tests" % app_name)
except (ImportError, AttributeError), e:
logging.error("Loading module %s.tests failed: '%s'." %
(app_name, e))
else:
suite.addTest(unittest.defaultTestLoader.loadTestsFromModule(
tests_mod))
#unittest.TextTestRunner(verbosity=verbosity).run(suite)
xmlrunner.XMLTestRunner(
verbose=False, descriptions=True, output='.').run(suite)
def do_runxmltest(target=('t', ''), verbosity=("v", 0)):
os.environ['SERVER_SOFTWARE'] = 'Dev-Test'
setup_env()
setup_stub()
runtest(target, verbosity)
action_xmltest = do_runxmltest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment