[ZPT] CVS: Packages/TAL - __init__.py:1.1 test_files.py:1.1 run.py:1.4

guido@digicool.com guido@digicool.com
Fri, 27 Apr 2001 16:09:15 -0400 (EDT)


Update of /cvs-repository/Packages/TAL/tests
In directory korak:/tmp/cvs-serv16260/tests

Modified Files:
	run.py 
Added Files:
	__init__.py test_files.py 
Log Message:
Add the file comparison test suite to the unit tests.  Make tests a package.


--- Added File __init__.py in package Packages/TAL ---
"""Empty file to make this directory a Python package."""

--- Added File test_files.py in package Packages/TAL ---
#! /usr/bin/env python1.5
"""Tests that run driver.py over input files comparing to output files."""

import os
import sys
import glob

import utils
import unittest

from TAL import runtest

class FileTestCase(unittest.TestCase):

    def __init__(self, file, dir):
        self.__file = file
        self.__dir = dir
        unittest.TestCase.__init__(self)

    def runTest(self):
        sys.stdout.write(os.path.basename(self.__file) + " ")
        sys.stdout.flush()
        sys.argv = ["", "-Q", self.__file]
        pwd = os.getcwd()
        try:
            try:
                os.chdir(self.__dir)
                runtest.main()
            finally:
                os.chdir(pwd)
        except SystemExit, what:
            if what.code:
                self.fail("output for %s didn't match" % self.__file)

try:
    script = __file__
except NameError:
    script = sys.argv[0]

def test_suite():
    suite = unittest.TestSuite()
    dir = os.path.dirname(script)
    dir = os.path.abspath(dir)
    parentdir = os.path.dirname(dir)
    prefix = os.path.join(dir, "input", "test*.")
    xmlargs = glob.glob(prefix + "xml")
    xmlargs.sort()
    htmlargs = glob.glob(prefix + "html")
    htmlargs.sort()
    args = xmlargs + htmlargs
    if not args:
        sys.stderr.write("Warning: no test input files found!!!\n")
    for arg in args:
        case = FileTestCase(arg, parentdir)
        suite.addTest(case)
    return suite

if __name__ == "__main__":
    errs = utils.run_suite(test_suite())
    sys.exit(errs and 1 or 0)

--- Updated File run.py in package Packages/TAL --
--- run.py	2001/04/10 02:48:49	1.3
+++ run.py	2001/04/27 20:09:13	1.4
@@ -8,6 +8,7 @@
 import test_htmltalparser
 import test_xmlparser
 import test_talinterpreter
+import test_files
 
 def test_suite():
     suite = unittest.TestSuite()
@@ -15,6 +16,7 @@
     suite.addTest(test_htmltalparser.test_suite())
     suite.addTest(test_xmlparser.test_suite())
     suite.addTest(test_talinterpreter.test_suite())
+    suite.addTest(test_files.test_suite())
     return suite
 
 def main():