|
Packit Service |
88ab54 |
# -*- coding: UTF-8 -*-
|
|
Packit Service |
88ab54 |
#
|
|
Packit Service |
88ab54 |
# $Id: tests.py 3425 2007-10-10 09:31:03Z dlaniel $
|
|
Packit Service |
88ab54 |
#
|
|
Packit Service |
88ab54 |
# Python unit tests for Lasso library
|
|
Packit Service |
88ab54 |
#
|
|
Packit Service |
88ab54 |
# Copyright (C) 2004-2007 Entr'ouvert
|
|
Packit Service |
88ab54 |
# http://lasso.entrouvert.org
|
|
Packit Service |
88ab54 |
#
|
|
Packit Service |
88ab54 |
# Authors: See AUTHORS file in top-level directory.
|
|
Packit Service |
88ab54 |
#
|
|
Packit Service |
88ab54 |
# This program is free software; you can redistribute it and/or modify
|
|
Packit Service |
88ab54 |
# it under the terms of the GNU General Public License as published by
|
|
Packit Service |
88ab54 |
# the Free Software Foundation; either version 2 of the License, or
|
|
Packit Service |
88ab54 |
# (at your option) any later version.
|
|
Packit Service |
88ab54 |
#
|
|
Packit Service |
88ab54 |
# This program is distributed in the hope that it will be useful,
|
|
Packit Service |
88ab54 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
88ab54 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
88ab54 |
# GNU General Public License for more details.
|
|
Packit Service |
88ab54 |
#
|
|
Packit Service |
88ab54 |
# You should have received a copy of the GNU General Public License
|
|
Packit Service |
88ab54 |
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
Packit Service |
88ab54 |
|
|
Packit Service |
88ab54 |
|
|
Packit Service |
88ab54 |
import __builtin__
|
|
Packit Service |
88ab54 |
import imp
|
|
Packit Service |
88ab54 |
from optparse import OptionParser
|
|
Packit Service |
88ab54 |
import os
|
|
Packit Service |
88ab54 |
import sys
|
|
Packit Service |
88ab54 |
import time
|
|
Packit Service |
88ab54 |
import unittest
|
|
Packit Service |
88ab54 |
|
|
Packit Service |
88ab54 |
from XmlTestRunner import XmlTestRunner
|
|
Packit Service |
88ab54 |
|
|
Packit Service |
88ab54 |
if not '..' in sys.path:
|
|
Packit Service |
88ab54 |
sys.path.insert(0, '..')
|
|
Packit Service |
88ab54 |
if not '../.libs' in sys.path:
|
|
Packit Service |
88ab54 |
sys.path.insert(0, '../.libs')
|
|
Packit Service |
88ab54 |
|
|
Packit Service |
88ab54 |
|
|
Packit Service |
88ab54 |
testSuites = [
|
|
Packit Service |
88ab54 |
'binding_tests',
|
|
Packit Service |
88ab54 |
'profiles_tests',
|
|
Packit Service |
88ab54 |
]
|
|
Packit Service |
88ab54 |
|
|
Packit Service |
88ab54 |
import lasso
|
|
Packit Service |
88ab54 |
if lasso.WSF_SUPPORT:
|
|
Packit Service |
88ab54 |
testSuites.append('idwsf1_tests')
|
|
Packit Service |
88ab54 |
testSuites.append('idwsf2_tests')
|
|
Packit Service |
88ab54 |
|
|
Packit Service |
88ab54 |
|
|
Packit Service |
88ab54 |
# Parse command line options.
|
|
Packit Service |
88ab54 |
parser = OptionParser()
|
|
Packit Service |
88ab54 |
parser.add_option(
|
|
Packit Service |
88ab54 |
'-x', '--xml', dest = 'xmlMode', help = 'enable XML output',
|
|
Packit Service |
88ab54 |
action = 'store_true', default = False)
|
|
Packit Service |
88ab54 |
parser.add_option(
|
|
Packit Service |
88ab54 |
'-s', '--source-dir', dest = 'srcDir', help = 'path of source directory',
|
|
Packit Service |
88ab54 |
metavar = 'DIR', default = os.getcwd())
|
|
Packit Service |
88ab54 |
(options, args) = parser.parse_args()
|
|
Packit Service |
88ab54 |
__builtin__.__dict__['dataDir'] = os.path.join(options.srcDir, '../../../tests/data')
|
|
Packit Service |
88ab54 |
|
|
Packit Service |
88ab54 |
if options.xmlMode:
|
|
Packit Service |
88ab54 |
print """"""
|
|
Packit Service |
88ab54 |
print """<testsuites xmlns="http://check.sourceforge.net/ns">"""
|
|
Packit Service |
88ab54 |
print """ <title>Python Bindings</title>"""
|
|
Packit Service |
88ab54 |
print """ <datetime>%s</datetime>""" % time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
|
|
Packit Service |
88ab54 |
|
|
Packit Service |
88ab54 |
success = True
|
|
Packit Service |
88ab54 |
for testSuite in testSuites:
|
|
Packit Service |
88ab54 |
fp, pathname, description = imp.find_module(testSuite)
|
|
Packit Service |
88ab54 |
try:
|
|
Packit Service |
88ab54 |
module = imp.load_module(testSuite, fp, pathname, description)
|
|
Packit Service |
88ab54 |
finally:
|
|
Packit Service |
88ab54 |
if fp:
|
|
Packit Service |
88ab54 |
fp.close()
|
|
Packit Service |
88ab54 |
if not module:
|
|
Packit Service |
88ab54 |
print >> sys.stderr, 'Unable to load test suite:', testSuite
|
|
Packit Service |
88ab54 |
continue
|
|
Packit Service |
88ab54 |
|
|
Packit Service |
88ab54 |
if module.__doc__:
|
|
Packit Service |
88ab54 |
doc = module.__doc__
|
|
Packit Service |
88ab54 |
else:
|
|
Packit Service |
88ab54 |
doc = testSuite
|
|
Packit Service |
88ab54 |
|
|
Packit Service |
88ab54 |
if options.xmlMode:
|
|
Packit Service |
88ab54 |
runner = XmlTestRunner()
|
|
Packit Service |
88ab54 |
else:
|
|
Packit Service |
88ab54 |
runner = unittest.TextTestRunner(verbosity=2)
|
|
Packit Service |
88ab54 |
print
|
|
Packit Service |
88ab54 |
print '-' * len(doc)
|
|
Packit Service |
88ab54 |
print doc
|
|
Packit Service |
88ab54 |
print '-' * len(doc)
|
|
Packit Service |
88ab54 |
result = runner.run(module.allTests)
|
|
Packit Service |
88ab54 |
success = success and result.wasSuccessful()
|
|
Packit Service |
88ab54 |
|
|
Packit Service |
88ab54 |
if options.xmlMode:
|
|
Packit Service |
88ab54 |
print """</testsuites>"""
|
|
Packit Service |
88ab54 |
|
|
Packit Service |
88ab54 |
sys.exit(not success)
|