diff options
author | R. Tyler Ballance <tyler@slide.com> | 2009-04-11 19:38:11 -0400 |
---|---|---|
committer | R. Tyler Ballance <tyler@slide.com> | 2009-04-11 19:38:11 -0400 |
commit | a0629df6e013515b40434c46dc60da02798bbe8f (patch) | |
tree | 3185442b6b29b02f24a2af75e5922cf1db29cc38 | |
parent | a87db1b880f7bb14d775e60261f7b228f518407a (diff) | |
download | python-cheetah-a0629df6e013515b40434c46dc60da02798bbe8f.tar.gz |
Add support for running the whole test-suite against the XMLTestRunner
In order to set up Hudson to run against a number of versions of Python,
we need to generate JUnit XML
Signed-off-by: R. Tyler Ballance <tyler@slide.com>
-rwxr-xr-x | src/Tests/Test.py | 65 | ||||
-rw-r--r-- | src/Tests/xmlrunner.py | 7 |
2 files changed, 24 insertions, 48 deletions
diff --git a/src/Tests/Test.py b/src/Tests/Test.py index d8a6a67..e168fc9 100755 --- a/src/Tests/Test.py +++ b/src/Tests/Test.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# $Id: Test.py,v 1.44 2006/01/15 20:45:10 tavis_rudd Exp $ -"""Core module of Cheetah's Unit-testing framework +''' +Core module of Cheetah's Unit-testing framework TODO ================================================================================ @@ -8,36 +8,12 @@ TODO # negative test cases for expected exceptions # black-box vs clear-box testing # do some tests that run the Template for long enough to check that the refresh code works - -Meta-Data -================================================================================ -Author: Tavis Rudd <tavis@damnsimple.com>, -License: This software is released for unlimited distribution under the - terms of the MIT license. See the LICENSE file. -Version: $Revision: 1.44 $ -Start Date: 2001/03/30 -Last Revision Date: $Date: 2006/01/15 20:45:10 $ -""" -__author__ = "Tavis Rudd <tavis@damnsimple.com>" -__revision__ = "$Revision: 1.44 $"[11:-2] - - -################################################## -## DEPENDENCIES ## +''' import sys import unittest_local_copy as unittest -################################################## -## CONSTANTS & GLOBALS - -try: - True, False -except NameError: - True, False = (1==1),(1==0) -################################################## -## TESTS import SyntaxAndOutput import NameMapper @@ -46,29 +22,26 @@ import CheetahWrapper import Regressions import Unicode -SyntaxSuite = unittest.findTestCases(SyntaxAndOutput) -NameMapperSuite = unittest.findTestCases(NameMapper) -TemplateSuite = unittest.findTestCases(Template) -Regressions = unittest.findTestCases(Regressions) -Unicode = unittest.findTestCases(Unicode) +suites = [ + unittest.findTestCases(SyntaxAndOutput), + unittest.findTestCases(NameMapper), + unittest.findTestCases(Template), + unittest.findTestCases(Regressions), + unittest.findTestCases(Unicode), +] if not sys.platform.startswith('java'): - CheetahWrapperSuite = unittest.findTestCases(CheetahWrapper) - -from SyntaxAndOutput import * -from NameMapper import * -from Template import * -from Regressions import * -from Unicode import * - -if not sys.platform.startswith('java'): - from CheetahWrapper import * - -################################################## -## if run from the command line + suites.append(unittest.findTestCases(CheetahWrapper)) if __name__ == '__main__': - unittest.main() + runner = unittest.TextTestRunner() + if 'xml' in sys.argv: + import xmlrunner + runner = xmlrunner.XMLTestRunner(filename='Cheetah-Tests.xml') + + results = runner.run(unittest.TestSuite(suites)) + + diff --git a/src/Tests/xmlrunner.py b/src/Tests/xmlrunner.py index a4fed9f..f280551 100644 --- a/src/Tests/xmlrunner.py +++ b/src/Tests/xmlrunner.py @@ -158,8 +158,9 @@ class XMLTestRunner(object): """ - def __init__(self, stream=None): - self._stream = stream + def __init__(self, *args, **kwargs): + self._stream = kwargs.get('stream') + self._filename = kwargs.get('filename') self._path = "." def run(self, test): @@ -168,6 +169,8 @@ class XMLTestRunner(object): classname = class_.__module__ + "." + class_.__name__ if self._stream == None: filename = "TEST-%s.xml" % classname + if self._filename: + filename = self._filename stream = file(os.path.join(self._path, filename), "w") stream.write('<?xml version="1.0" encoding="utf-8"?>\n') else: |