#!/usr/bin/env python
from nose.suite import ContextSuite
from nose.plugins.xunit import Xunit
from nose.plugins.plugintest import run_buffered as run
from nose.plugins.skip import SkipTest, Skip
import fnmatch
import os
from nose.loader import TestLoader
from nose.core import TestProgram
file_pattern = 'test_*.pyc'
suite = ContextSuite()
for root, dir_names, file_names in os.walk('.'):
for file_name in file_names:
if fnmatch.fnmatch(file_name, 'test_*.py'):
file_pattern = 'test_*.py'
break
path = 'ksa.tests.'
if root != '.':
path += root.replace('/', '.')
path = '{0}.'.format(path.replace('...', '.'))
for test_case in fnmatch.filter(file_names, file_pattern):
modname = path + os.path.splitext(test_case)[0]
module = __import__(modname, globals(), locals(), ['1'])
suite.addTest(TestLoader().loadTestsFromModule(module))
outfile = os.path.join(os.path.dirname(__file__), 'nosetests.xml')
argv = ['nosetests', '-v', '--with-xunit',
'--xunit-file=%s' % outfile]
#run(argv=argv, plugins=[Xunit(), Skip()], suite=suite)
TestProgram(suite=suite, plugins=[Xunit(), Skip()], argv=argv)