[Checkins] SVN: z3c.rml/trunk/src/z3c/rml/ Added tests for DTD and reference generator. Also removed some dead code.

Stephen Richter cvs-admin at zope.org
Fri Dec 21 15:36:02 UTC 2012


Log message for revision 128847:
  Added tests for DTD and reference generator. Also removed some dead code.
  

Changed:
  U   z3c.rml/trunk/src/z3c/rml/dtd.py
  D   z3c.rml/trunk/src/z3c/rml/error.py
  U   z3c.rml/trunk/src/z3c/rml/reference.py
  U   z3c.rml/trunk/src/z3c/rml/rml-reference.pdf
  U   z3c.rml/trunk/src/z3c/rml/rml.dtd
  U   z3c.rml/trunk/src/z3c/rml/special.py
  A   z3c.rml/trunk/src/z3c/rml/tests/test_dtd.py
  A   z3c.rml/trunk/src/z3c/rml/tests/test_reference.py

-=-
Modified: z3c.rml/trunk/src/z3c/rml/dtd.py
===================================================================
--- z3c.rml/trunk/src/z3c/rml/dtd.py	2012-12-21 15:05:38 UTC (rev 128846)
+++ z3c.rml/trunk/src/z3c/rml/dtd.py	2012-12-21 15:36:01 UTC (rev 128847)
@@ -77,7 +77,3 @@
 
 def main():
     print generate()
-
-
-if __name__ == '__main__':
-    print main()

Deleted: z3c.rml/trunk/src/z3c/rml/error.py
===================================================================
--- z3c.rml/trunk/src/z3c/rml/error.py	2012-12-21 15:05:38 UTC (rev 128846)
+++ z3c.rml/trunk/src/z3c/rml/error.py	2012-12-21 15:36:01 UTC (rev 128847)
@@ -1,42 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2007 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (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.
-#
-##############################################################################
-"""RML-specific XML tools
-
-$Id$
-"""
-__docformat__ = "reStructuredText"
-import sys
-
-ERROR_FILE = sys.stderr
-
-class ParseException(Exception):
-    pass
-
-class RequiredAttributeMissing(ParseException):
-
-    def __init__(self, element, name):
-        self.element = element
-        self.name = name
-
-    def __str__(self):
-        return "%r attribute of %r element is required but missing." % (
-            self.name, self.element.tag)
-
-
-
-def reportUnsupportedAttribute(element, name):
-    ERROR_FILE.write(
-        "'%s' attribute of '%s' element is not yet supported." % (
-            name, element.tag)
-        )

Modified: z3c.rml/trunk/src/z3c/rml/reference.py
===================================================================
--- z3c.rml/trunk/src/z3c/rml/reference.py	2012-12-21 15:05:38 UTC (rev 128846)
+++ z3c.rml/trunk/src/z3c/rml/reference.py	2012-12-21 15:36:01 UTC (rev 128847)
@@ -231,7 +231,7 @@
     return examples
 
 
-def main():
+def main(outPath=None):
     examples = extractExamples(EXAMPLES_DIRECTORY)
 
     template = pagetemplate.RMLPageTemplateFile('reference.pt')
@@ -241,8 +241,4 @@
     directives = sorted(directives.values(), key=lambda d: d['name'])
 
     pdf = template(types=getAttributeTypes(), directives=directives)
-    open('rml-reference.pdf', 'wb').write(pdf)
-
-
-if __name__ == '__main__':
-    main()
+    open(outPath or 'rml-reference.pdf', 'wb').write(pdf)

Modified: z3c.rml/trunk/src/z3c/rml/rml-reference.pdf
===================================================================
--- z3c.rml/trunk/src/z3c/rml/rml-reference.pdf	2012-12-21 15:05:38 UTC (rev 128846)
+++ z3c.rml/trunk/src/z3c/rml/rml-reference.pdf	2012-12-21 15:36:01 UTC (rev 128847)
@@ -16884,7 +16884,7 @@
 % 'R1041': class PDFInfo 
 1041 0 obj
 << /Author (Zope Community)
- /CreationDate (D:20121221015105+05'00')
+ /CreationDate (D:20121221103522+05'00')
  /Creator (\(unspecified\))
  /Keywords ()
  /Producer (ReportLab PDF Library - www.reportlab.com)
@@ -21104,7 +21104,7 @@
 trailer
 << /ID 
  % ReportLab generated PDF document -- digest (http://www.reportlab.com) 
- [(\254\266\356\237\252\335!\022\220\230\310f\207@\277\337) (\254\266\356\237\252\335!\022\220\230\310f\207@\277\337)] 
+ [(\221\306\260\325NL\354\236\236_k\210~[\226\215) (\221\306\260\325NL\354\236\236_k\210~[\226\215)] 
 
  /Info 1041 0 R
  /Root 1040 0 R

Modified: z3c.rml/trunk/src/z3c/rml/rml.dtd
===================================================================
--- z3c.rml/trunk/src/z3c/rml/rml.dtd	2012-12-21 15:05:38 UTC (rev 128846)
+++ z3c.rml/trunk/src/z3c/rml/rml.dtd	2012-12-21 15:36:01 UTC (rev 128847)
@@ -2205,4 +2205,3 @@
 <!ELEMENT plugInGraphic (#PCDATA)>
 <!ATTLIST plugInGraphic module CDATA #REQUIRED>
 <!ATTLIST plugInGraphic function CDATA #REQUIRED>
-

Modified: z3c.rml/trunk/src/z3c/rml/special.py
===================================================================
--- z3c.rml/trunk/src/z3c/rml/special.py	2012-12-21 15:05:38 UTC (rev 128846)
+++ z3c.rml/trunk/src/z3c/rml/special.py	2012-12-21 15:36:01 UTC (rev 128847)
@@ -41,33 +41,6 @@
         manager.names[id] = value
 
 
-class IGetName(interfaces.IRMLDirectiveSignature):
-    """Get the text for the id."""
-
-    id = attr.String(
-        title=u'Id',
-        description=u'The id as which the value is known.',
-        required=True)
-
-class GetName(directive.RMLDirective):
-    signature = IGetName
-
-    def process(self):
-        id = dict(self.getAttributeValues()).pop('id')
-        manager = attr.getManager(self)
-        try:
-            text = manager.names[id] + (self.element.tail or u'')
-        except:
-            import pdb; pdb.set_trace()
-        # Now replace the element with the text
-        parent = self.element.getparent()
-        if parent.text is None:
-            parent.text = text
-        else:
-            parent.text += text
-        parent.remove(self.element)
-
-
 class IAlias(interfaces.IRMLDirectiveSignature):
     """Defines an alias for a given style."""
 

Added: z3c.rml/trunk/src/z3c/rml/tests/test_dtd.py
===================================================================
--- z3c.rml/trunk/src/z3c/rml/tests/test_dtd.py	                        (rev 0)
+++ z3c.rml/trunk/src/z3c/rml/tests/test_dtd.py	2012-12-21 15:36:01 UTC (rev 128847)
@@ -0,0 +1,31 @@
+##############################################################################
+#
+# Copyright (c) 2012 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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 PARTLAR PURPOSE.
+#
+##############################################################################
+"""Test generating DTD
+"""
+import os
+import unittest
+from z3c.rml import dtd
+
+class DTDTestCase(unittest.TestCase):
+
+    level = 2
+
+    def runTest(self):
+        path = os.path.join(os.path.dirname(dtd.__file__), 'rml.dtd')
+        with open(path, 'w') as file:
+            file.write(dtd.generate())
+
+
+def test_suite():
+   return unittest.TestSuite([DTDTestCase()])


Property changes on: z3c.rml/trunk/src/z3c/rml/tests/test_dtd.py
___________________________________________________________________
Added: svn:keywords
   + Id

Added: z3c.rml/trunk/src/z3c/rml/tests/test_reference.py
===================================================================
--- z3c.rml/trunk/src/z3c/rml/tests/test_reference.py	                        (rev 0)
+++ z3c.rml/trunk/src/z3c/rml/tests/test_reference.py	2012-12-21 15:36:01 UTC (rev 128847)
@@ -0,0 +1,31 @@
+##############################################################################
+#
+# Copyright (c) 2012 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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 PARTLAR PURPOSE.
+#
+##############################################################################
+"""Test generating reference.
+"""
+import os
+import unittest
+from z3c.rml import reference
+
+class ReferenceTestCase(unittest.TestCase):
+
+    level = 3
+
+    def runTest(self):
+        reference.main(
+            os.path.join(os.path.dirname(reference.__file__),
+                         'rml-reference.pdf'))
+
+
+def test_suite():
+   return unittest.TestSuite([ReferenceTestCase()])


Property changes on: z3c.rml/trunk/src/z3c/rml/tests/test_reference.py
___________________________________________________________________
Added: svn:keywords
   + Id



More information about the checkins mailing list