2005-12-08 17:15:52 +00:00
|
|
|
# -*- coding: iso-8859-1 -*-
|
2008-01-02 14:31:19 +00:00
|
|
|
# Copyright (C) 2005-2008 Bastian Kleineidam
|
2005-12-08 17:15:52 +00:00
|
|
|
#
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
|
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
"""
|
2005-12-17 19:22:44 +00:00
|
|
|
Test utilities.
|
2005-12-08 17:15:52 +00:00
|
|
|
"""
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def make_suite (prefix, namespace):
|
2008-04-27 11:39:21 +00:00
|
|
|
"""Add all TestCase classes starting with given prefix to a test suite.
|
2005-12-08 17:15:52 +00:00
|
|
|
|
|
|
|
|
@return: test suite
|
|
|
|
|
@rtype: unittest.TestSuite
|
|
|
|
|
"""
|
2006-02-03 22:15:41 +00:00
|
|
|
classes = [value for key, value in namespace.iteritems() \
|
2005-12-08 17:15:52 +00:00
|
|
|
if (key.startswith(prefix) or key.startswith('Test')) \
|
|
|
|
|
and issubclass(value, unittest.TestCase)]
|
|
|
|
|
loader = unittest.defaultTestLoader
|
|
|
|
|
tests = [loader.loadTestsFromTestCase(clazz) for clazz in classes]
|
|
|
|
|
return unittest.TestSuite(tests)
|