[Checkins] SVN: z3c.form/branches/adamg-z3c-pt-optional/ test pass now

Adam Groszer agroszer at gmail.com
Sun May 24 05:18:23 EDT 2009


Log message for revision 100327:
  test pass now
  

Changed:
  U   z3c.form/branches/adamg-z3c-pt-optional/buildout.cfg
  U   z3c.form/branches/adamg-z3c-pt-optional/setup.py
  U   z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/adding.txt
  U   z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/browser/README.txt
  U   z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/browser/object.txt
  U   z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/browser/objectmulti.txt
  U   z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/browser/tests.py
  A   z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/compatibility.py
  U   z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/form.txt
  U   z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/group.txt
  A   z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/ptcompat.py
  U   z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/testing.py

-=-
Modified: z3c.form/branches/adamg-z3c-pt-optional/buildout.cfg
===================================================================
--- z3c.form/branches/adamg-z3c-pt-optional/buildout.cfg	2009-05-24 09:15:29 UTC (rev 100326)
+++ z3c.form/branches/adamg-z3c-pt-optional/buildout.cfg	2009-05-24 09:18:23 UTC (rev 100327)
@@ -10,6 +10,8 @@
 [versions]
 z3c.form=
 lxml = 2.1.1
+zc.sourcefactory = 0.4.0
+zope.container = 3.8.1
 #
 #####################################################
 

Modified: z3c.form/branches/adamg-z3c-pt-optional/setup.py
===================================================================
--- z3c.form/branches/adamg-z3c-pt-optional/setup.py	2009-05-24 09:15:29 UTC (rev 100326)
+++ z3c.form/branches/adamg-z3c-pt-optional/setup.py	2009-05-24 09:18:23 UTC (rev 100327)
@@ -82,6 +82,7 @@
         test = [
             'zope.app.testing',
             'zope.app.container',
+            'zope.container',
             'zope.app.pagetemplate',
             'zope.app.i18n',
             'zope.testing',

Modified: z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/adding.txt
===================================================================
--- z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/adding.txt	2009-05-24 09:15:29 UTC (rev 100326)
+++ z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/adding.txt	2009-05-24 09:18:23 UTC (rev 100327)
@@ -35,7 +35,7 @@
 
 Next we need a container to which we wish to add the person:
 
-  >>> from zope.container import btree
+  >>> from zope.app.container import btree
   >>> people = btree.BTreeContainer()
 
 When creating and adding a new object using the ``IAdding`` API, the container

Modified: z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/browser/README.txt
===================================================================
--- z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/browser/README.txt	2009-05-24 09:15:29 UTC (rev 100326)
+++ z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/browser/README.txt	2009-05-24 09:18:23 UTC (rev 100327)
@@ -15,10 +15,12 @@
 
   >>> from zope.configuration import xmlconfig
   >>> import zope.component
+  >>> import zope.app.component
   >>> import zope.app.security
   >>> import zope.i18n
   >>> import z3c.form
   >>> xmlconfig.XMLConfig('meta.zcml', zope.component)()
+  >>> xmlconfig.XMLConfig('meta.zcml', zope.app.component)()
   >>> xmlconfig.XMLConfig('meta.zcml', zope.app.security)()
   >>> xmlconfig.XMLConfig('meta.zcml', zope.i18n)()
   >>> xmlconfig.XMLConfig('meta.zcml', z3c.form)()

Modified: z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/browser/object.txt
===================================================================
--- z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/browser/object.txt	2009-05-24 09:15:29 UTC (rev 100326)
+++ z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/browser/object.txt	2009-05-24 09:18:23 UTC (rev 100327)
@@ -562,12 +562,12 @@
   4
 
   >>> printEvents()
-  <zope.lifecycleevent.ObjectCreatedEvent object at ...>
-  <zope.lifecycleevent.ObjectModifiedEvent object at ...>
+  <zope...ObjectCreatedEvent object at ...>
+  <zope...ObjectModifiedEvent object at ...>
   <InterfaceClass z3c.form.testing.IMySubObject>
   ('foofield', 'barfield')
-  <zope.lifecycleevent.ObjectCreatedEvent object at ...>
-  <zope.container.contained.ContainerModifiedEvent object at ...>
+  <zope...ObjectCreatedEvent object at ...>
+  <zope...contained.ContainerModifiedEvent object at ...>
 
 
   >>> eventlog=[]
@@ -662,10 +662,10 @@
   2
 
   >>> printEvents()
-  <zope.lifecycleevent.ObjectModifiedEvent object at ...>
+  <zope...ObjectModifiedEvent object at ...>
   <InterfaceClass z3c.form.testing.IMySubObject>
   ('foofield', 'barfield')
-  <zope.lifecycleevent.ObjectModifiedEvent object at ...>
+  <zope...ObjectModifiedEvent object at ...>
   <InterfaceClass z3c.form.testing.IMyObject>
   ('subobject',)
 
@@ -1146,10 +1146,10 @@
   >>> len(eventlog)
   2
   >>> printEvents()
-  <zope.lifecycleevent.ObjectModifiedEvent object at ...>
+  <zope...ObjectModifiedEvent object at ...>
   <InterfaceClass z3c.form.testing.IMySubObject>
   ('foofield', 'barfield')
-  <zope.lifecycleevent.ObjectModifiedEvent object at ...>
+  <zope...ObjectModifiedEvent object at ...>
   <InterfaceClass z3c.form.testing.IMyObject>
   ('subobject', 'name')
 

Modified: z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/browser/objectmulti.txt
===================================================================
--- z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/browser/objectmulti.txt	2009-05-24 09:15:29 UTC (rev 100326)
+++ z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/browser/objectmulti.txt	2009-05-24 09:18:23 UTC (rev 100327)
@@ -1276,16 +1276,16 @@
 ((why is IMySubObjectMulti created twice???))
 
   >>> printEvents()
-  <zope.lifecycleevent.ObjectCreatedEvent object at ...>
-  <zope.lifecycleevent.ObjectModifiedEvent object at ...>
+  <zope...ObjectCreatedEvent object at ...>
+  <zope...ObjectModifiedEvent object at ...>
   <InterfaceClass z3c.form.testing.IMySubObjectMulti>
   ('foofield', 'barfield')
-  <zope.lifecycleevent.ObjectCreatedEvent object at ...>
-  <zope.lifecycleevent.ObjectModifiedEvent object at ...>
+  <zope...ObjectCreatedEvent object at ...>
+  <zope...ObjectModifiedEvent object at ...>
   <InterfaceClass z3c.form.testing.IMySubObjectMulti>
   ('foofield', 'barfield')
-  <zope.lifecycleevent.ObjectCreatedEvent object at ...>
-  <zope.container.contained.ContainerModifiedEvent object at ...>
+  <zope...ObjectCreatedEvent object at ...>
+  <zope...contained.ContainerModifiedEvent object at ...>
 
 
   >>> eventlog=[]
@@ -1415,19 +1415,19 @@
 ((TODO: now this is real crap here, why is IMySubObjectMulti created 3 times???))
 
   >>> printEvents()
-  <zope.lifecycleevent.ObjectCreatedEvent object at ...>
-  <zope.lifecycleevent.ObjectModifiedEvent object at ...>
+  <zope...ObjectCreatedEvent object at ...>
+  <zope...ObjectModifiedEvent object at ...>
   <InterfaceClass z3c.form.testing.IMySubObjectMulti>
   ('foofield', 'barfield')
-  <zope.lifecycleevent.ObjectCreatedEvent object at ...>
-  <zope.lifecycleevent.ObjectModifiedEvent object at ...>
+  <zope...ObjectCreatedEvent object at ...>
+  <zope...ObjectModifiedEvent object at ...>
   <InterfaceClass z3c.form.testing.IMySubObjectMulti>
   ('foofield', 'barfield')
-  <zope.lifecycleevent.ObjectCreatedEvent object at ...>
-  <zope.lifecycleevent.ObjectModifiedEvent object at ...>
+  <zope...ObjectCreatedEvent object at ...>
+  <zope...ObjectModifiedEvent object at ...>
   <InterfaceClass z3c.form.testing.IMySubObjectMulti>
   ('foofield', 'barfield')
-  <zope.lifecycleevent.ObjectModifiedEvent object at ...>
+  <zope...ObjectModifiedEvent object at ...>
   <InterfaceClass z3c.form.testing.IMyMultiObject>
   ('listOfObject',)
 
@@ -1578,8 +1578,8 @@
 ((TODO: bummer... who creates those 2 objects???))
 
   >>> printEvents()
-  <zope.lifecycleevent.ObjectCreatedEvent object at ...>
-  <zope.lifecycleevent.ObjectCreatedEvent object at ...>
+  <zope...ObjectCreatedEvent object at ...>
+  <zope...ObjectCreatedEvent object at ...>
 
 
 Watch for the error message in the HTML:

Modified: z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/browser/tests.py
===================================================================
--- z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/browser/tests.py	2009-05-24 09:15:29 UTC (rev 100326)
+++ z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/browser/tests.py	2009-05-24 09:18:23 UTC (rev 100327)
@@ -23,10 +23,16 @@
 from zope.testing.doctestunit import DocFileSuite
 
 from z3c.form import testing
+from z3c.form.ptcompat import AVAILABLE
 
 def test_suite():
     checker = testing.OutputChecker(doctest)
 
+    if AVAILABLE:
+        setups = (testing.setUpZPT, testing.setUpZ3CPT)
+    else:
+        setups = (testing.setUpZPT,)
+
     tests = ((
         DocFileSuite('README.txt',
                      setUp=setUp, tearDown=testing.tearDown,
@@ -118,6 +124,6 @@
                      optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
                      checker=checker,
                      ))
-             for setUp in (testing.setUpZPT, testing.setUpZ3CPT))
+             for setUp in setups)
 
     return unittest.TestSuite(itertools.chain(*tests))

Added: z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/compatibility.py
===================================================================
--- z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/compatibility.py	                        (rev 0)
+++ z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/compatibility.py	2009-05-24 09:18:23 UTC (rev 100327)
@@ -0,0 +1,56 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Form and Widget Framework Interfaces
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+import datetime
+import decimal
+import zope.interface
+
+def addTimeField():
+    """Add ITime interface and Time field to zope.schema.
+
+    Target: Zope 3.3
+    """
+    from zope.schema import interfaces
+    if hasattr(interfaces, 'ITime'):
+        return
+
+    class ITime(interfaces.IMinMax, interfaces.IField):
+        u"""Field containing a time."""
+    interfaces.ITime = ITime
+
+    class Time(zope.schema.Orderable, zope.schema.Field):
+        __doc__ = ITime.__doc__
+        zope.interface.implements(ITime)
+        _type = datetime.time
+    zope.schema.Time = Time
+
+def addHooks():
+    try:
+        from zope.site import hooks
+        return
+    except AttributeError:
+        #this is a crappy situation
+        import zope.location.interfaces
+        import zope.traversing.interfaces
+        zope.location.interfaces.IRoot = zope.traversing.interfaces.IContainmentRoot
+        import zope.site
+        import zope.app.component.hooks
+        zope.site.hooks = zope.app.component.hooks
+
+def apply():
+    addHooks()


Property changes on: z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/compatibility.py
___________________________________________________________________
Added: svn:keywords
   + Date Author Id Revision
Added: svn:eol-style
   + native

Modified: z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/form.txt
===================================================================
--- z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/form.txt	2009-05-24 09:15:29 UTC (rev 100326)
+++ z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/form.txt	2009-05-24 09:18:23 UTC (rev 100327)
@@ -918,7 +918,7 @@
 
   >>> event = eventlog[-1]
   >>> event
-  <zope.lifecycleevent.ObjectModifiedEvent object at ...>
+  <zope...ObjectModifiedEvent object at ...>
 
   >>> attrs = event.descriptions[0]
   >>> attrs.interface

Modified: z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/group.txt
===================================================================
--- z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/group.txt	2009-05-24 09:15:29 UTC (rev 100326)
+++ z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/group.txt	2009-05-24 09:18:23 UTC (rev 100327)
@@ -445,7 +445,7 @@
 
   >>> event = eventlog[-1]
   >>> event
-  <zope.lifecycleevent.ObjectModifiedEvent object at ...>
+  <zope...ObjectModifiedEvent object at ...>
 
 The event's description contains the changed Interface and the names of
 all changed fields, even if they where in different groups:
@@ -467,7 +467,7 @@
   ...     fields = field.Fields(IVehicleRegistration).select(
   ...         'firstName', 'lastName')
   ...
-  ...     template = viewpagetemplatefile.ViewPageTemplateFile(
+  ...     template = ViewPageTemplateFile(
   ...         'simple_groupedit.pt', os.path.dirname(tests.__file__))
 
   >>> request = testing.TestRequest()
@@ -606,7 +606,7 @@
   ...         'owner')
   ...     groups = (OwnerGroup,)
   ...
-  ...     template = viewpagetemplatefile.ViewPageTemplateFile(
+  ...     template = ViewPageTemplateFile(
   ...         'simple_groupedit.pt', os.path.dirname(tests.__file__))
 
   >>> reg = VehicleRegistration(
@@ -746,13 +746,13 @@
   ...         'owner')
   ...     groups = (OwnerGroup,)
   ...
-  ...     template = viewpagetemplatefile.ViewPageTemplateFile(
+  ...     template = ViewPageTemplateFile(
   ...         'simple_groupedit.pt', os.path.dirname(tests.__file__))
 
   >>> class RegistrationEditForm(group.GroupForm, form.EditForm):
   ...     groups = (VehicleRegistrationGroup,)
   ...
-  ...     template = viewpagetemplatefile.ViewPageTemplateFile(
+  ...     template = ViewPageTemplateFile(
   ...         'simple_nested_groupedit.pt', os.path.dirname(tests.__file__))
 
   >>> reg = VehicleRegistration(

Added: z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/ptcompat.py
===================================================================
--- z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/ptcompat.py	                        (rev 0)
+++ z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/ptcompat.py	2009-05-24 09:18:23 UTC (rev 100327)
@@ -0,0 +1,32 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""z3c.pt optional compatibility
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+
+try:
+    from z3c.ptcompat import ViewPageTemplateFile
+    AVAILABLE = True
+except ImportError:
+    AVAILABLE = False
+
+if AVAILABLE:
+    #ViewPageTemplateFile = ptcompat.ViewPageTemplateFile
+    from z3c.ptcompat import bind_template
+else:
+    from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
+    from zope.app.pagetemplate.viewpagetemplatefile import BoundPageTemplate \
+         as bind_template


Property changes on: z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/ptcompat.py
___________________________________________________________________
Added: svn:keywords
   + Date Author Id Revision
Added: svn:eol-style
   + native

Modified: z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/testing.py
===================================================================
--- z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/testing.py	2009-05-24 09:15:29 UTC (rev 100326)
+++ z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/testing.py	2009-05-24 09:18:23 UTC (rev 100327)
@@ -39,8 +39,8 @@
 
 from z3c.form.ptcompat import AVAILABLE
 
-from z3c.ptcompat.testing import render
-from z3c.ptcompat.testing import OutputChecker
+#from z3c.ptcompat.testing import render
+#from z3c.ptcompat.testing import OutputChecker
 
 import lxml.html
 import lxml.doctestcompare
@@ -357,3 +357,96 @@
 
 def tearDown(test):
     setup.placefulTearDown()
+
+
+##########################
+import doctest as pythondoctest
+
+import lxml.etree
+import lxml.doctestcompare
+
+import re
+
+class OutputChecker(lxml.doctestcompare.LHTMLOutputChecker):
+    """Doctest output checker which is better equippied to identify
+    HTML markup than the checker from the ``lxml.doctestcompare``
+    module. It also uses the text comparison function from the
+    built-in ``doctest`` module to allow the use of ellipsis."""
+
+    _repr_re = re.compile(r'^<([A-Z]|[^>]+ (at|object) |[a-z]+ \'[A-Za-z0-9_.]+\'>)')
+
+    def __init__(self, doctest=pythondoctest):
+        self.doctest = doctest
+
+        # make sure these optionflags are registered
+        doctest.register_optionflag('PARSE_HTML')
+        doctest.register_optionflag('PARSE_XML')
+        doctest.register_optionflag('NOPARSE_MARKUP')
+
+    def _looks_like_markup(self, s):
+        s = s.replace('<BLANKLINE>', '\n').strip()
+        return (s.startswith('<')
+                and not self._repr_re.search(s))
+
+    def text_compare(self, want, got, strip):
+        if want is None: want = ""
+        if got is None: got = ""
+        checker = self.doctest.OutputChecker()
+        return checker.check_output(
+            want, got, self.doctest.ELLIPSIS|self.doctest.NORMALIZE_WHITESPACE)
+
+    def get_parser(self, want, got, optionflags):
+        NOPARSE_MARKUP = self.doctest.OPTIONFLAGS_BY_NAME.get(
+            "NOPARSE_MARKUP", 0)
+        PARSE_HTML = self.doctest.OPTIONFLAGS_BY_NAME.get(
+            "PARSE_HTML", 0)
+        PARSE_XML = self.doctest.OPTIONFLAGS_BY_NAME.get(
+            "PARSE_XML", 0)
+
+        parser = None
+        if NOPARSE_MARKUP & optionflags:
+            return None
+        if PARSE_HTML & optionflags:
+            parser = lxml.doctestcompare.html_fromstring
+        elif PARSE_XML & optionflags:
+            parser = lxml.etree.XML
+        elif (want.strip().lower().startswith('<html')
+              and got.strip().startswith('<html')):
+            parser = lxml.doctestcompare.html_fromstring
+        elif (self._looks_like_markup(want)
+              and self._looks_like_markup(got)):
+            parser = self.get_default_parser()
+        return parser
+
+def render(view, xpath='.'):
+    method = getattr(view, 'render', None)
+    if method is None:
+        method = view.__call__
+
+    string = method()
+    if string == "":
+        return string
+
+    try:
+        root = lxml.etree.fromstring(string)
+    except lxml.etree.XMLSyntaxError:
+        root = lxml.html.fromstring(string)
+
+    output = ""
+    for node in root.xpath(
+        xpath, namespaces={'xmlns': 'http://www.w3.org/1999/xhtml'}):
+        s = lxml.etree.tounicode(node, pretty_print=True)
+        s = s.replace(' xmlns="http://www.w3.org/1999/xhtml"', ' ')
+        output += s
+
+    if not output:
+        raise ValueError("No elements matched by %s." % repr(xpath))
+
+    # let's get rid of blank lines
+    output = output.replace('\n\n', '\n')
+
+    # self-closing tags are more readable with a space before the
+    # end-of-tag marker
+    output = output.replace('"/>', '" />')
+
+    return output
\ No newline at end of file



More information about the Checkins mailing list