[Zope-Checkins] CVS: Zope3/lib/python/Zope/TAL/tests - __init__.py:1.2 run.py:1.7 test_files.py:1.6 test_htmltalparser.py:1.29 test_sourcepos.py:1.3 test_talinterpreter.py:1.4 test_xmlparser.py:1.7 utils.py:1.6 test_htmlparser.py:NONE

Jim Fulton jim@zope.com
Mon, 10 Jun 2002 19:30:15 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/TAL/tests
In directory cvs.zope.org:/tmp/cvs-serv20468/lib/python/Zope/TAL/tests

Modified Files:
	__init__.py run.py test_files.py test_htmltalparser.py 
	test_sourcepos.py test_talinterpreter.py test_xmlparser.py 
	utils.py 
Removed Files:
	test_htmlparser.py 
Log Message:
Merged Zope-3x-branch into newly forked Zope3 CVS Tree.

=== Zope3/lib/python/Zope/TAL/tests/__init__.py 1.1 => 1.2 ===
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+# 
+##############################################################################
 """Empty file to make this directory a Python package."""


=== Zope3/lib/python/Zope/TAL/tests/run.py 1.6 => 1.7 ===
+#! /usr/bin/env python
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+# 
+##############################################################################
 """Run all tests."""
 
 import sys
 import utils
 import unittest
-import test_htmlparser
 import test_htmltalparser
 import test_talinterpreter
 import test_files
@@ -12,7 +24,6 @@
 
 def test_suite():
     suite = unittest.TestSuite()
-    suite.addTest(test_htmlparser.test_suite())
     suite.addTest(test_htmltalparser.test_suite())
     if not utils.skipxml:
         import test_xmlparser


=== Zope3/lib/python/Zope/TAL/tests/test_files.py 1.5 => 1.6 ===
+#! /usr/bin/env python
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+# 
+##############################################################################
 """Tests that run driver.py over input files comparing to output files."""
 
 import os
 import sys
 import glob
 
-from TAL.tests import utils
+from Zope.TAL.tests import utils
 import unittest
 
-from TAL import runtest
+from Zope.TAL import runtest
 
 class FileTestCase(unittest.TestCase):
 
@@ -21,7 +34,7 @@
         basename = os.path.basename(self.__file)
         #sys.stdout.write(basename + " ")
         sys.stdout.flush()
-        if basename[:10] == 'test_metal':
+        if basename.startswith('test_metal'):
             sys.argv = ["", "-Q", "-m", self.__file]
         else:
             sys.argv = ["", "-Q", self.__file]


=== Zope3/lib/python/Zope/TAL/tests/test_htmltalparser.py 1.28 => 1.29 ===
+#! /usr/bin/env python
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+# 
+##############################################################################
 """Tests for the HTMLTALParser code generator."""
 
 import pprint
 import sys
 
-from TAL.tests import utils
+from Zope.TAL.tests import utils
 import unittest
 
-from string import rfind
 
-from TAL import HTMLTALParser
-from TAL.TALDefs import TAL_VERSION, TALError, METALError
+from Zope.TAL import HTMLTALParser
+from Zope.TAL.TALDefs import TAL_VERSION, TALError, METALError
 
 
 class TestCaseBase(unittest.TestCase):
@@ -24,7 +36,7 @@
         if p1 and p2:
             op1, args1 = p1[-1]
             op2, args2 = p2[0]
-            if op1[:7] == 'rawtext' and op2[:7] == 'rawtext':
+            if op1.startswith('rawtext') and op2.startswith('rawtext'):
                 return (p1[:-1]
                         + [rawtext(args1[0] + args2[0])]
                         + p2[1:])
@@ -60,7 +72,7 @@
 def rawtext(s):
     """Compile raw text to the appropriate instruction."""
     if "\n" in s:
-        return ("rawtextColumn", (s, len(s) - (rfind(s, "\n") + 1)))
+        return ("rawtextColumn", (s, len(s) - (s.rfind("\n") + 1)))
     else:
         return ("rawtextOffset", (s, len(s)))
 
@@ -99,25 +111,6 @@
         def check(self=self):
             self._run_check("<a><b></a></b>", [])
         self.assertRaises(HTMLTALParser.NestingError, check)
-
-    def check_cdata_mode(self):
-        """This routine should NOT detect an error with an end tag </a></b> not
-           matching the start <script> tag.  The contents are within a
-           HTML comment, and should be ignored.
-        """
-        # The above comment is not generally true.  The HTML 4 specification
-        # gives <script> a CDATA content model, which means comments are not
-        # syntactically recognized (those characters contribute to the text
-        # content of the <script> element).  The '</a' in the '</a>' causes
-        # the SGML markup-in-context rules to kick in, and '</a>' should then
-        # be recognized as an improperly nested end tag.  See:
-        # http://www.w3.org/TR/html401/types.html#type-cdata
-        #
-        s = """<html><script>\n<!--\ndocument.write("</a></b>");\n// -->\n</script></html>"""
-        output = [
-            rawtext(s),
-            ]
-        self._run_check(s, output)
 
     def check_code_attr_syntax(self):
         output = [


=== Zope3/lib/python/Zope/TAL/tests/test_sourcepos.py 1.2 => 1.3 ===
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+# 
+##############################################################################
 """Tests for TALInterpreter."""
 
 import sys
@@ -6,10 +19,10 @@
 
 from StringIO import StringIO
 
-from TAL.HTMLTALParser import HTMLTALParser
-from TAL.TALInterpreter import TALInterpreter
-from TAL.TALGenerator import TALGenerator
-from TAL.DummyEngine import DummyEngine
+from Zope.TAL.HTMLTALParser import HTMLTALParser
+from Zope.TAL.TALInterpreter import TALInterpreter
+from Zope.TAL.TALGenerator import TALGenerator
+from Zope.TAL.DummyEngine import DummyEngine
 
 
 page1 = '''<html metal:use-macro="main"><body>


=== Zope3/lib/python/Zope/TAL/tests/test_talinterpreter.py 1.3 => 1.4 ===
+#! /usr/bin/env python
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+# 
+##############################################################################
 """Tests for TALInterpreter."""
 
 import sys
 
-from TAL.tests import utils
+from Zope.TAL.tests import utils
 import unittest
 
 from StringIO import StringIO
 
-from TAL.TALDefs import METALError
-from TAL.HTMLTALParser import HTMLTALParser
-from TAL.TALInterpreter import TALInterpreter
-from TAL.DummyEngine import DummyEngine
+from Zope.TAL.TALDefs import METALError
+from Zope.TAL.HTMLTALParser import HTMLTALParser
+from Zope.TAL.TALInterpreter import TALInterpreter
+from Zope.TAL.DummyEngine import DummyEngine
 
 
 class TestCaseBase(unittest.TestCase):


=== Zope3/lib/python/Zope/TAL/tests/test_xmlparser.py 1.6 => 1.7 ===
+#! /usr/bin/env python
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+# 
+##############################################################################
 """Tests for XMLParser.py."""
 
-import string
 import sys
+from types import ListType
 
-from TAL.tests import utils
+from Zope.TAL.tests import utils
 import unittest
 
-from TAL import XMLParser
+from Zope.TAL import XMLParser
 
 
 class EventCollector(XMLParser.XMLParser):
@@ -88,14 +101,11 @@
 
     def _run_check(self, source, events, collector=EventCollector):
         parser = collector()
-        if isinstance(source, type([])):
+        if isinstance(source, ListType):
             parser.parseStream(SegmentedFile(source))
         else:
             parser.parseString(source)
-        if utils.oldexpat:
-            while events[0][0] in ('decl', 'doctype'):
-                del events[0]
-        self.assertEquals(parser.get_events(), events)
+        self.assertEquals(parser.get_events(),events)
 
     def _run_check_extra(self, source, events):
         self._run_check(source, events, EventCollectorExtra)


=== Zope3/lib/python/Zope/TAL/tests/utils.py 1.5 => 1.6 ===
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+# 
+##############################################################################
 """Helper functions for the test suite."""
 
 import os
 import sys
 
 mydir = os.path.abspath(os.path.dirname(__file__))
-codedir = os.path.dirname(os.path.dirname(mydir))
+codedir = os.path.dirname(os.path.dirname(os.path.dirname(mydir)))
 
 if codedir not in sys.path:
     sys.path.append(codedir)
@@ -13,7 +26,6 @@
 
 
 # Set skipxml to true if an XML parser could not be found.
-pyexpat = None
 skipxml = 0
 try:
     import pyexpat
@@ -23,23 +35,6 @@
         import xml.parsers.pyexpat
     except ImportError:
         skipxml = 1
-    else:
-        pyexpat = xml.parsers.pyexpat
-
-
-# Set oldexpat if the StartDoctypeDeclHandler and XmlDeclHandler are
-# not supported.  The tests need to know whether the events reported
-# by those handlers should be expected, but need to make sure the
-# right thing is returned if they are.
-oldexpat = 0
-if pyexpat is not None:
-    p = pyexpat.ParserCreate()
-    # Can't use hasattr() since pyexpat supports the handler
-    # attributes in a broken way.
-    try:
-        p.StartDoctypeDeclHandler = None
-    except AttributeError:
-        oldexpat = 1
 
 
 def run_suite(suite, outf=None, errf=None):

=== Removed File Zope3/lib/python/Zope/TAL/tests/test_htmlparser.py ===