[ZPT] CVS: Packages/TAL - test_talinterpreter.py:1.1 run.py:1.3

guido@digicool.com guido@digicool.com
Mon, 9 Apr 2001 22:48:50 -0400 (EDT)


Update of /cvs-repository/Packages/TAL/test
In directory korak:/tmp/cvs-serv14775

Modified Files:
	run.py 
Added Files:
	test_talinterpreter.py 
Log Message:
Add tests for macro call version/mode checks.


--- Added File test_talinterpreter.py in package Packages/TAL ---
#! /usr/bin/env python1.5
"""Tests for TALInterpreter."""

import sys

import utils
import unittest

from TAL.TALDefs import METALError
from TAL.HTMLTALParser import HTMLTALParser
from TAL.TALInterpreter import TALInterpreter
from TAL.DummyEngine import DummyEngine


class MacroErrorsTestCase(unittest.TestCase):

    def _compile(self, source):
        parser = HTMLTALParser()
        parser.parseString(source)
        program, macros = parser.getCode()
        return program, macros

    def setUp(self):
        dummy, macros = self._compile('<p metal:define-macro="M">Booh</p>')
        self.macro = macros['M']
        self.engine = DummyEngine(macros)
        program, dummy = self._compile('<p metal:use-macro="M">Bah</p>')
        self.interpreter = TALInterpreter(program, {}, self.engine)

    def tearDown(self):
        try:
            self.interpreter()
        except METALError:
            pass
        else:
            self.fail("Expected METALError")

    def check_mode_error(self):
        self.macro[1] = ("mode", "duh")

    def check_version_error(self):
        self.macro[0] = ("version", "duh")


def test_suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(MacroErrorsTestCase, "check_"))
    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/03/26 19:21:07	1.2
+++ run.py	2001/04/10 02:48:49	1.3
@@ -7,12 +7,14 @@
 import test_htmlparser
 import test_htmltalparser
 import test_xmlparser
+import test_talinterpreter
 
 def test_suite():
     suite = unittest.TestSuite()
     suite.addTest(test_htmlparser.test_suite())
     suite.addTest(test_htmltalparser.test_suite())
     suite.addTest(test_xmlparser.test_suite())
+    suite.addTest(test_talinterpreter.test_suite())
     return suite
 
 def main():