[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form/tests - support.py:1.1.2.1 test_configure.py:1.1.4.1 test_add.py:1.13.12.1 test_browserwidget.py:1.10.14.1 test_checkboxwidget.py:1.6.14.1 test_editview.py:1.8.14.1 test_filewidget.py:1.4.14.1 test_listwidget.py:1.5.14.1 test_multicheckboxwidget.py:1.5.14.1 test_multilistwidget.py:1.5.14.1 test_passwordwidget.py:1.5.14.1 test_radiowidget.py:1.6.14.1 test_textareawidget.py:1.5.14.1 test_textwidget.py:1.4.14.1 test_vocabularywidget.py:1.3.2.1

Grégoire Weber zope@i-con.ch
Sun, 22 Jun 2003 10:24:11 -0400


Update of /cvs-repository/Zope3/src/zope/app/browser/form/tests
In directory cvs.zope.org:/tmp/cvs-serv24874/src/zope/app/browser/form/tests

Modified Files:
      Tag: cw-mail-branch
	test_add.py test_browserwidget.py test_checkboxwidget.py 
	test_editview.py test_filewidget.py test_listwidget.py 
	test_multicheckboxwidget.py test_multilistwidget.py 
	test_passwordwidget.py test_radiowidget.py 
	test_textareawidget.py test_textwidget.py 
	test_vocabularywidget.py 
Added Files:
      Tag: cw-mail-branch
	support.py test_configure.py 
Log Message:
Synced up with HEAD

=== Added File Zope3/src/zope/app/browser/form/tests/support.py ===
##############################################################################
#
# Copyright (c) 2003 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.
#
##############################################################################

"""General test support."""


class VerifyResults:
    """Mix-in for test classes with helpers for checking string data."""

    def verifyResult(self, result, check_list, inorder=False):
        start = 0
        for check in check_list:
            pos = result.find(check, start)
            self.assert_(pos >= 0,
                         "%r not found in %r" % (check, result[start:]))
            if inorder:
                start = pos + len(check)

    def verifyResultMissing(self, result, check_list):
        for check in check_list:
            self.assert_(result.find(check) < 0,
                         "%r unexpectedly found in %r" % (check, result))


=== Added File Zope3/src/zope/app/browser/form/tests/test_configure.py ===
##############################################################################
#
# Copyright (c) 2003 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.
#
##############################################################################

"""Test that the package's configure.zcml can be loaded."""

import unittest

from zope.app.tests.placelesssetup import PlacelessSetup
from zope.configuration.tests.test_xml import TempFile
from zope.configuration.xmlconfig import XMLConfig


class TestBrowserFormZCML(PlacelessSetup, unittest.TestCase):

    def test_load_zcml(self):
        text = """\
        <zopeConfigure xmlns='http://namespaces.zope.org/zope'>
          <include package='zope.configuration' file='metameta.zcml' />
          <include package='zope.app.component' file='meta.zcml' />
          <include package='zope.app.event' file='meta.zcml' />
          <include package='zope.app.publisher.browser' file='meta.zcml' />

          <include package='zope.app.browser.form' />
        </zopeConfigure>
        """
        f = TempFile()
        try:
            f.write(text)
            f.flush()
            x = XMLConfig(f.name)
            x()
        finally:
            f.close()


def test_suite():
    return unittest.makeSuite(TestBrowserFormZCML)

if __name__ == '__main__':
    unittest.main(defaultTest="test_suite")


=== Zope3/src/zope/app/browser/form/tests/test_add.py 1.13 => 1.13.12.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_add.py:1.13	Wed Apr 30 19:37:52 2003
+++ Zope3/src/zope/app/browser/form/tests/test_add.py	Sun Jun 22 10:22:40 2003
@@ -20,7 +20,7 @@
 import unittest
 
 from zope.app.browser.form.add import add, AddViewFactory, AddView
-from zope.interface import Interface
+from zope.interface import Interface, implements
 from zope.schema import TextLine, accessors
 from zope.app.interfaces.container import IAdding
 from zope.publisher.interfaces.browser import IBrowserPresentation
@@ -48,7 +48,7 @@
 
 class I(Interface):
 
-    name_ = TextLine()
+    name = TextLine()
     first = TextLine()
     last = TextLine()
     email = TextLine()
@@ -59,7 +59,7 @@
 
 class C:
 
-    __implements__ = (I, )
+    implements(I)
 
     def __init__(self, *args, **kw):
         self.args = args
@@ -69,22 +69,22 @@
     def setfoo(self, v): self._foo = v
 
 class V:
-    name_ = CustomWidget(Text)
-    first = CustomWidget(Text)
-    last = CustomWidget(Text)
-    email = CustomWidget(Text)
-    address = CustomWidget(Text)
-    getfoo = CustomWidget(Text)
-    extra1 = CustomWidget(Text)
-    extra2 = CustomWidget(Text)
+    name_widget = CustomWidget(Text)
+    first_widget = CustomWidget(Text)
+    last_widget = CustomWidget(Text)
+    email_widget = CustomWidget(Text)
+    address_widget = CustomWidget(Text)
+    getfoo_widget = CustomWidget(Text)
+    extra1_widget = CustomWidget(Text)
+    extra2_widget = CustomWidget(Text)
 
 class FooV:
-    bar = CustomWidget(Text)
+    bar_widget = CustomWidget(Text)
 
 
 class SampleData:
 
-    name_ = u"foo"
+    name = u"foo"
     first = u"bar"
     last = u"baz"
     email = u"baz@dot.com"
@@ -123,7 +123,7 @@
 
         result1 = self._invoke_add()
         result2 = self._invoke_add(
-            fields="name_ first last email address getfoo extra1 extra2",
+            fields="name first last email address getfoo extra1 extra2",
             )
 
         self.assertEqual(result1, result2)
@@ -152,7 +152,7 @@
         self.assertEqual(bases, (V, AddView, ))
         self.assertEqual(for_, IAdding)
         self.assertEqual(" ".join(fields),
-                         "name_ first last email address getfoo extra1 extra2")
+                         "name first last email address getfoo extra1 extra2")
         self.assertEqual(content_factory, C)
         self.assertEqual(" ".join(arguments),
                          "first last")
@@ -161,7 +161,7 @@
         self.assertEqual(" ".join(set_before_add),
                          "getfoo")
         self.assertEqual(" ".join(set_after_add),
-                         "extra1 name_ address extra2")
+                         "extra1 name address extra2")
         self.failIf(kw)
 
         return args
@@ -170,7 +170,7 @@
 
         class Adding:
 
-            __implements__ = IAdding
+            implements(IAdding)
 
             def __init__(self, test):
                 self.test = test
@@ -202,7 +202,7 @@
 
         class Adding:
 
-            __implements__ = IAdding
+            implements(IAdding)
 
             def __init__(self, test):
                 self.test = test
@@ -229,14 +229,14 @@
 
         self.assertEqual(adding.ob.extra1, "extra1")
         self.assertEqual(adding.ob.extra2, "extra2")
-        self.assertEqual(adding.ob.name_, "foo")
+        self.assertEqual(adding.ob.name, "foo")
         self.assertEqual(adding.ob.address, "aa")
 
     def test_createAndAdd_w_adapter(self):
 
         class Adding:
 
-            __implements__ = IAdding
+            implements(IAdding)
 
             def __init__(self, test):
                 self.test = test
@@ -264,7 +264,7 @@
     def test_hooks(self):
 
         class Adding:
-            __implements__ = IAdding
+            implements(IAdding)
 
         adding = Adding()
         [(descriminator, callable, args, kw)] = self._invoke_add()
@@ -303,7 +303,7 @@
 
             self.assertEqual(l[0].extra1, "extra1")
             self.assertEqual(l[0].extra2, "extra2")
-            self.assertEqual(l[0].name_, "foo")
+            self.assertEqual(l[0].name, "foo")
             self.assertEqual(l[0].address, "aa")
 
             self.assertEqual(request.response.getHeader("Location"), "next")


=== Zope3/src/zope/app/browser/form/tests/test_browserwidget.py 1.10 => 1.10.14.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_browserwidget.py:1.10	Fri Apr  4 10:39:29 2003
+++ Zope3/src/zope/app/browser/form/tests/test_browserwidget.py	Sun Jun 22 10:22:40 2003
@@ -26,9 +26,13 @@
 from zope.schema import Text
 import os
 import unittest
+from zope.testing.doctestunit import DocTestSuite
+from zope.app.browser.form.tests import support
 import zope.app.browser.form.tests
 
-class BrowserWidgetTest(PlacelessSetup, unittest.TestCase):
+class BrowserWidgetTest(PlacelessSetup,
+                        support.VerifyResults,
+                        unittest.TestCase):
 
     _FieldFactory = Text
     _WidgetFactory = BrowserWidget
@@ -40,11 +44,6 @@
         request.form['field.foo'] = u'Foo Value'
         self._widget = self._WidgetFactory(field, request)
 
-    def _verifyResult(self, result, check_list):
-        for check in check_list:
-            self.assertNotEqual(-1, result.find(check),
-                                '"'+check+'" not found in "'+result+'"')
-
     def test_required(self):
         self._widget.context.required = False
         self.failIf(self._widget.required)
@@ -66,12 +65,13 @@
         value = 'Foo Value'
         check_list = ('type="text"', 'id="field.foo"', 'name="field.foo"',
                       'value="Foo Value"')
-        self._verifyResult(self._widget.render(value), check_list)
+        self._widget.setData(value)
+        self.verifyResult(self._widget(), check_list)
         check_list = ('type="hidden"',) + check_list[1:]
-        self._verifyResult(self._widget.renderHidden(value), check_list)
+        self.verifyResult(self._widget.hidden(), check_list)
         check_list = ('type="hidden"', 'style="color: red"') + check_list[1:]
         self._widget.extra = 'style="color: red"'
-        self._verifyResult(self._widget.renderHidden(value), check_list)
+        self.verifyResult(self._widget.hidden(), check_list)
 
     def testLabel(self):
         label = ' '.join(self._widget.label().strip().split())
@@ -161,7 +161,10 @@
 
 
 def test_suite():
-    return unittest.makeSuite(Test)
+    suite = unittest.TestSuite()
+    suite.addTest(unittest.makeSuite(Test))
+    suite.addTest(DocTestSuite("zope.app.browser.form.widget"))
+    return suite
 
 if __name__ == '__main__':
     unittest.main(defaultTest='test_suite')


=== Zope3/src/zope/app/browser/form/tests/test_checkboxwidget.py 1.6 => 1.6.14.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_checkboxwidget.py:1.6	Tue Apr  8 17:34:22 2003
+++ Zope3/src/zope/app/browser/form/tests/test_checkboxwidget.py	Sun Jun 22 10:22:40 2003
@@ -36,23 +36,19 @@
 
     def testRender(self):
         value = 1
+        self._widget.setData(value)
         check_list = ('type="checkbox"', 'id="field.foo"',
                       'name="field.foo"', 'checked="checked"')
-        self._verifyResult(self._widget.render(value), check_list)
+        self.verifyResult(self._widget(), check_list)
         value = 0
+        self._widget.setData(value)
         check_list = check_list[:-1]
-        self._verifyResult(self._widget.render(value), check_list)
+        self.verifyResult(self._widget(), check_list)
         check_list = ('type="hidden"',) + check_list[1:-1]
-        self._verifyResult(self._widget.renderHidden(value), check_list)
+        self.verifyResult(self._widget.hidden(), check_list)
         check_list = ('style="color: red"',) + check_list
         self._widget.extra = 'style="color: red"'
-        self._verifyResult(self._widget.renderHidden(value), check_list)
-
-    def test_haveData(self):
-        # Checkbox always has data
-        self.failUnless(self._widget.haveData())
-        del self._widget.request.form['field.foo']
-        self.failUnless(self._widget.haveData())
+        self.verifyResult(self._widget.hidden(), check_list)
 
     def test_getData(self):
         self._widget.request.form['field.foo'] = 'on'


=== Zope3/src/zope/app/browser/form/tests/test_editview.py 1.8 => 1.8.14.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_editview.py:1.8	Mon Apr 14 04:27:15 2003
+++ Zope3/src/zope/app/browser/form/tests/test_editview.py	Sun Jun 22 10:22:40 2003
@@ -17,7 +17,7 @@
 
 from zope.app.tests.placelesssetup import PlacelessSetup
 from zope.app.event.tests.placelesssetup import getEvents
-from zope.interface import Interface
+from zope.interface import Interface, implements
 from zope.schema import TextLine, accessors
 from zope.schema.interfaces import ITextLine
 from zope.publisher.browser import TestRequest
@@ -40,7 +40,7 @@
     schema = I
 
 class C:
-    __implements__ = (I, )
+    implements(I)
     foo = u"c foo"
     bar = u"c bar"
     a   = u"c a"
@@ -58,7 +58,7 @@
     bar = TextLine(title=u"Bar")
 
 class Foo:
-    __implements__ = IFoo
+    implements(IFoo)
 
     foo = 'Foo foo'
 


=== Zope3/src/zope/app/browser/form/tests/test_filewidget.py 1.4 => 1.4.14.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_filewidget.py:1.4	Tue Apr  8 17:34:22 2003
+++ Zope3/src/zope/app/browser/form/tests/test_filewidget.py	Sun Jun 22 10:22:40 2003
@@ -43,14 +43,16 @@
 
     def testRender(self):
         value = 'Foo Value'
+        self._widget.setData(value)
         check_list = ('type="file"', 'id="field.foo"', 'name="field.foo"',
                       'size="20"')
-        self._verifyResult(self._widget.render(value), check_list)
+
+        self.verifyResult(self._widget(), check_list)
         check_list = ('type="hidden"',) + check_list[1:-1]
-        self._verifyResult(self._widget.renderHidden(value), check_list)
+        self.verifyResult(self._widget.hidden(), check_list)
         check_list = ('style="color: red"',) + check_list
         self._widget.extra = 'style="color: red"'
-        self._verifyResult(self._widget.renderHidden(value), check_list)
+        self.verifyResult(self._widget.hidden(), check_list)
 
 
 


=== Zope3/src/zope/app/browser/form/tests/test_listwidget.py 1.5 => 1.5.14.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_listwidget.py:1.5	Tue Apr  8 17:34:22 2003
+++ Zope3/src/zope/app/browser/form/tests/test_listwidget.py	Sun Jun 22 10:22:40 2003
@@ -36,11 +36,11 @@
 
     def testRenderItem(self):
         check_list = ('option', 'value="foo"', 'Foo')
-        self._verifyResult(
+        self.verifyResult(
             self._widget.renderItem(0, 'Foo', 'foo', 'field.bar', None),
             check_list)
         check_list += ('selected="selected"',)
-        self._verifyResult(
+        self.verifyResult(
             self._widget.renderSelectedItem(
                 0, 'Foo', 'foo', 'field.bar', None),
             check_list)
@@ -49,8 +49,8 @@
     def testRenderItems(self):
         check_list = ('option', 'value="foo"', 'bar',
                       'value="foo"', 'foo', 'selected="selected"')
-        self._verifyResult('\n'.join(self._widget.renderItems('foo')),
-                           check_list)
+        self.verifyResult('\n'.join(self._widget.renderItems('foo')),
+                          check_list)
 
 
     def testRender(self):
@@ -58,14 +58,15 @@
         check_list = ('select', 'id="field.foo"', 'name="field.foo"',
                       'size="5"', 'option', 'value="foo"', '>foo<',
                       'value="foo"', '>bar<', 'selected="selected"')
-        self._verifyResult(self._widget.render(value), check_list)
+        self._widget.setData(value)
+        self.verifyResult(self._widget(), check_list)
 
         check_list = ('type="hidden"', 'id="field.foo"', 'name="field.foo"',
                       'value="foo"')
-        self._verifyResult(self._widget.renderHidden(value), check_list)
+        self.verifyResult(self._widget.hidden(), check_list)
         check_list = ('style="color: red"',) + check_list
         self._widget.extra = 'style="color: red"'
-        self._verifyResult(self._widget.renderHidden(value), check_list)
+        self.verifyResult(self._widget.hidden(), check_list)
 
 
 


=== Zope3/src/zope/app/browser/form/tests/test_multicheckboxwidget.py 1.5 => 1.5.14.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_multicheckboxwidget.py:1.5	Tue Apr  8 17:34:22 2003
+++ Zope3/src/zope/app/browser/form/tests/test_multicheckboxwidget.py	Sun Jun 22 10:22:40 2003
@@ -36,11 +36,11 @@
     def testRenderItem(self):
         check_list = ('type="checkbox"', 'id="field.bar"',
                       'name="field.bar"', 'value="foo"', 'Foo')
-        self._verifyResult(
+        self.verifyResult(
             self._widget.renderItem(0, 'Foo', 'foo', 'field.bar', None),
             check_list)
         check_list += ('checked="checked"',)
-        self._verifyResult(
+        self.verifyResult(
             self._widget.renderSelectedItem(
                 0, 'Foo', 'foo', 'field.bar', None),
             check_list)
@@ -50,23 +50,24 @@
         check_list = ('type="checkbox"', 'id="field.foo"',
                       'name="field.foo"', 'value="bar"', 'bar',
                       'value="foo"', 'foo', 'checked="checked"')
-        self._verifyResult('\n'.join(self._widget.renderItems('bar')),
-                           check_list)
+        self.verifyResult('\n'.join(self._widget.renderItems('bar')),
+                          check_list)
 
 
     def testRender(self):
         value = 'bar'
+        self._widget.setData(value)
         check_list = ('type="checkbox"', 'id="field.foo"',
                       'name="field.foo"', 'value="bar"', 'bar',
                       'value="foo"', 'foo', 'checked="checked"')
-        self._verifyResult(self._widget.render(value), check_list)
+        self.verifyResult(self._widget(), check_list)
 
         check_list = ('type="hidden"', 'id="field.foo"', 'name="field.foo"',
                       'value="bar"')
-        self._verifyResult(self._widget.renderHidden(value), check_list)
+        self.verifyResult(self._widget.hidden(), check_list)
         check_list = ('style="color: red"',) + check_list
         self._widget.extra = 'style="color: red"'
-        self._verifyResult(self._widget.renderHidden(value), check_list)
+        self.verifyResult(self._widget.hidden(), check_list)
 
 
 def test_suite():


=== Zope3/src/zope/app/browser/form/tests/test_multilistwidget.py 1.5 => 1.5.14.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_multilistwidget.py:1.5	Tue Apr  8 17:34:22 2003
+++ Zope3/src/zope/app/browser/form/tests/test_multilistwidget.py	Sun Jun 22 10:22:40 2003
@@ -35,11 +35,11 @@
 
     def testRenderItem(self):
         check_list = ('option', 'value="foo"', 'Foo')
-        self._verifyResult(
+        self.verifyResult(
             self._widget.renderItem(0, 'Foo', 'foo', 'field.bar', None),
             check_list)
         check_list += ('selected="selected"',)
-        self._verifyResult(
+        self.verifyResult(
             self._widget.renderSelectedItem(
                 0, 'Foo', 'foo', 'field.bar', None),
             check_list)
@@ -47,24 +47,25 @@
     def testRenderItems(self):
         check_list = ('option', 'value="foo"', 'bar',
                       'value="foo"', 'foo', 'selected="selected"')
-        self._verifyResult('\n'.join(self._widget.renderItems('foo')),
-                           check_list)
+        self.verifyResult('\n'.join(self._widget.renderItems('foo')),
+                          check_list)
 
 
     def testRender(self):
         value = 'foo'
+        self._widget.setData(value)
         check_list = ('select', 'id="field.foo"', 'name="field.foo"',
                       'size="5"', 'option', 'value="foo"', '>foo<',
                       'value="foo"', '>bar<', 'selected="selected"',
                       'multiple="multiple"')
-        self._verifyResult(self._widget.render(value), check_list)
+        self.verifyResult(self._widget(), check_list)
 
         check_list = ('type="hidden"', 'id="field.foo"', 'name="field.foo"',
                       'value="foo"')
-        self._verifyResult(self._widget.renderHidden(value), check_list)
+        self.verifyResult(self._widget.hidden(), check_list)
         check_list = ('style="color: red"',) + check_list
         self._widget.extra = 'style="color: red"'
-        self._verifyResult(self._widget.renderHidden(value), check_list)
+        self.verifyResult(self._widget.hidden(), check_list)
 
 
 


=== Zope3/src/zope/app/browser/form/tests/test_passwordwidget.py 1.5 => 1.5.14.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_passwordwidget.py:1.5	Tue Apr  8 17:34:22 2003
+++ Zope3/src/zope/app/browser/form/tests/test_passwordwidget.py	Sun Jun 22 10:22:40 2003
@@ -35,9 +35,10 @@
 
     def testRender(self):
         value = 'Foo Value'
+        self._widget.setData(value)
         check_list = ('type="password"', 'id="field.foo"',
                       'name="field.foo"', 'value=""', 'size="20"')
-        self._verifyResult(self._widget.render(value), check_list)
+        self.verifyResult(self._widget(), check_list)
 
     def testHidden(self):
         self.assertRaises(NotImplementedError, self._widget.hidden)


=== Zope3/src/zope/app/browser/form/tests/test_radiowidget.py 1.6 => 1.6.14.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_radiowidget.py:1.6	Tue Apr  8 17:34:22 2003
+++ Zope3/src/zope/app/browser/form/tests/test_radiowidget.py	Sun Jun 22 10:22:40 2003
@@ -37,11 +37,11 @@
     def testRenderItem(self):
         check_list = ('type="radio"', 'id="field.bar.0"',
                       'name="field.bar"', 'value="foo"', 'Foo')
-        self._verifyResult(
+        self.verifyResult(
             self._widget.renderItem(0, 'Foo', 'foo', 'field.bar', None),
             check_list)
         check_list += ('checked="checked"',)
-        self._verifyResult(
+        self.verifyResult(
             self._widget.renderSelectedItem(
                 0, 'Foo', 'foo', 'field.bar', None),
             check_list)
@@ -51,23 +51,24 @@
         check_list = ('type="radio"', 'id="field.foo.0"', 'name="field.foo"',
                       'value="bar"', 'bar', 'value="foo"', 'foo',
                       'checked="checked"')
-        self._verifyResult('\n'.join(self._widget.renderItems('bar')),
-                           check_list)
+        self.verifyResult('\n'.join(self._widget.renderItems('bar')),
+                          check_list)
 
 
     def testRender(self):
         value = 'bar'
+        self._widget.setData(value)
         check_list = ('type="radio"', 'id="field.foo.0"',
                       'name="field.foo"', 'value="bar"', 'bar',
                       'value="foo"', 'foo', 'checked="checked"')
-        self._verifyResult(self._widget.render(value), check_list)
+        self.verifyResult(self._widget(), check_list)
 
         check_list = ('type="hidden"', 'id="field.foo"',
                       'name="field.foo"', 'value="bar"')
-        self._verifyResult(self._widget.renderHidden(value), check_list)
+        self.verifyResult(self._widget.hidden(), check_list)
         check_list = ('style="color: red"',) + check_list
         self._widget.extra = 'style="color: red"'
-        self._verifyResult(self._widget.renderHidden(value), check_list)
+        self.verifyResult(self._widget.hidden(), check_list)
 
     def testLabel(self):
         label = ' '.join(self._widget.label().strip().split())


=== Zope3/src/zope/app/browser/form/tests/test_textareawidget.py 1.5 => 1.5.14.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_textareawidget.py:1.5	Tue Apr  8 17:34:22 2003
+++ Zope3/src/zope/app/browser/form/tests/test_textareawidget.py	Sun Jun 22 10:22:40 2003
@@ -34,15 +34,16 @@
 
     def testRender(self):
         value = "Foo Value"
+        self._widget.setData(value)
         check_list = ('rows="15"', 'cols="60"', 'id="field.foo"',
                       'name="field.foo"', 'textarea')
-        self._verifyResult(self._widget.render(value), check_list)
+        self.verifyResult(self._widget(), check_list)
         check_list = ('style="color: red"',) + check_list
         self._widget.extra = 'style="color: red"'
-        self._verifyResult(self._widget.render(value), check_list)
+        self.verifyResult(self._widget(), check_list)
         check_list = ('type="hidden"', 'id="field.foo"', 'name="field.foo"',
                       'value="Foo Value"')
-        self._verifyResult(self._widget.renderHidden(value), check_list)
+        self.verifyResult(self._widget.hidden(), check_list)
 
     def testRow(self):
         self._widget.request.form.clear()


=== Zope3/src/zope/app/browser/form/tests/test_textwidget.py 1.4 => 1.4.14.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_textwidget.py:1.4	Tue Apr  8 16:02:14 2003
+++ Zope3/src/zope/app/browser/form/tests/test_textwidget.py	Sun Jun 22 10:22:40 2003
@@ -35,14 +35,15 @@
 
     def testRender(self):
         value = 'Foo Value'
+        self._widget.setData(value)
         check_list = ('type="text"', 'id="field.foo"', 'name="field.foo"',
                       'value="Foo Value"', 'size="20"')
-        self._verifyResult(self._widget.render(value), check_list)
+        self.verifyResult(self._widget(), check_list)
         check_list = ('type="hidden"',) + check_list[1:-1]
-        self._verifyResult(self._widget.renderHidden(value), check_list)
+        self.verifyResult(self._widget.hidden(), check_list)
         check_list = ('style="color: red"',) + check_list
         self._widget.extra = 'style="color: red"'
-        self._verifyResult(self._widget.renderHidden(value), check_list)
+        self.verifyResult(self._widget.hidden(), check_list)
 
 
 


=== Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py 1.3 => 1.3.2.1 ===
--- Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py:1.3	Wed May 21 20:39:33 2003
+++ Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py	Sun Jun 22 10:22:40 2003
@@ -17,70 +17,30 @@
 import unittest
 
 from zope.app.browser.form import vocabularywidget
+from zope.app.browser.form.tests import support
 from zope.app.interfaces.browser.form import IBrowserWidget
 from zope.app.interfaces.browser.form import IVocabularyQueryView
 from zope.app.tests.placelesssetup import PlacelessSetup
 from zope.component import getView
 from zope.component.view import provideView
+from zope.interface.declarations import implements
 from zope.publisher.browser import TestRequest
 from zope.publisher.interfaces.browser import IBrowserPresentation
 
-from zope.schema.interfaces import IVocabulary, ITerm, IVocabularyQuery
-from zope.schema.interfaces import IVocabularyField, IVocabularyMultiField
+from zope.schema.interfaces import IVocabulary, IVocabularyQuery
+from zope.schema.interfaces import IVocabularyField, IVocabularyListField
 from zope.schema.interfaces import IIterableVocabularyQuery
+from zope.schema.interfaces import IVocabularyTokenized
 from zope.schema import vocabulary
 
 
-class ISampleVocabulary(IVocabulary):
+class ISampleVocabulary(IVocabularyTokenized, IVocabulary):
     """Specialized interface so we can hook views onto a vocabulary."""
 
-class SampleTerm(object):
-    """Trivial ITerm implementation."""
-    __implements__ = ITerm
 
-    def __init__(self, value):
-        self.value = value
-
-
-class BasicVocabulary(object):
-    """Simple vocabulary that uses terms from a passed-in list of values."""
-    __implements__ = IVocabulary
-
-    def __init__(self, values):
-        self._values = values
-
-    def __contains__(self, value):
-        return value in self._values
-
-    def __iter__(self):
-        return BasicIterator(self._values)
-
-    def __len__(self):
-        return len(self._values)
-
-    def getQuery(self):
-        return None
-
-    def getTerm(self, value):
-        if value in self._values:
-            return SampleTerm(value)
-        raise LookupError("%r not a vocabulary member" % value)
-
-class BasicIterator(object):
-    """Iterator that produces ITerm objects from vocabulary data."""
-
-    def __init__(self, values):
-        self._next = iter(values).next
-
-    def __iter__(self):
-        return self
-
-    def next(self):
-        return SampleTerm(self._next())
-
-class SampleVocabulary(BasicVocabulary):
+class SampleVocabulary(vocabulary.SimpleVocabulary):
     """Vocabulary used to test vocabulary-based specialization of widgets."""
-    __implements__ = ISampleVocabulary
+    implements(ISampleVocabulary)
 
 
 class SampleDisplayWidget(vocabularywidget.VocabularyWidgetBase):
@@ -88,9 +48,9 @@
 
     This is not intended to be a useful widget.
     """
-    __implements__ = IBrowserWidget
+    implements(IBrowserWidget)
 
-    def render(self, value):
+    def __call__(self):
         return "foo"
 
 
@@ -98,7 +58,7 @@
     """Stub content object used by makeField()."""
 
 
-class QueryVocabulary(BasicVocabulary):
+class QueryVocabulary(vocabulary.SimpleVocabulary):
     """Vocabulary that offer simple query support."""
 
     def getQuery(self):
@@ -112,14 +72,18 @@
 class MyVocabularyQuery:
     """Vocabulary query object which query views can be registered for."""
 
-    __implements__ = IMyVocabularyQuery
+    implements(IMyVocabularyQuery)
 
     def __init__(self, vocabulary):
         self.vocabulary = vocabulary
 
 
-class MyQueryViewBase(vocabularywidget.VocabularyQueryViewBase):
-    """Base class for test query views."""
+class MyQueryViewSingle(vocabularywidget.VocabularyQueryViewBase):
+    """Single-selection vocabulary query view."""
+
+    implements(IVocabularyQueryView)
+
+    label = "single"
 
     def getResults(self):
         return self.request.form.get(self.name)
@@ -131,25 +95,15 @@
         return "query-results-go-here"
 
 
-class MyQueryViewSingle(MyQueryViewBase):
-    """Single-selection vocabulary query view."""
-
-    __implements__ = IVocabularyQueryView
-
-    def getLabel(self):
-        return "single"
-
-
-class MyQueryViewMulti(MyQueryViewBase):
+class MyQueryViewMulti(MyQueryViewSingle):
     """Multi-selection vocabulary query view."""
 
-    __implements__ = IVocabularyQueryView
-
-    def getLabel(self):
-        return "multi"
+    label = "multi"
 
 
-class VocabularyWidgetTestBase(PlacelessSetup, unittest.TestCase):
+class VocabularyWidgetTestBase(PlacelessSetup,
+                               support.VerifyResults,
+                               unittest.TestCase):
     """Base class for all the vocabulary widget tests.
 
     This class provides version helper methods.
@@ -165,9 +119,12 @@
     # fieldClass -- class for the vocabulary field (VocabularyField or
     #               VocabularyMultiField)
 
-    def makeField(self, vocabulary, value=_marker):
+    def makeField(self, vocabulary=None, value=_marker, required=False):
         """Create and return a bound vocabulary field."""
-        field = self.fieldClass(vocabulary=vocabulary, __name__="f")
+        if vocabulary is None:
+            vocabulary = self.sampleVocabulary
+        field = self.fieldClass(vocabulary=vocabulary, __name__="f",
+                                required=required)
         content = SampleContent()
         if value is self._marker:
             value = self.defaultFieldValue
@@ -186,19 +143,6 @@
             tr.processInputs()
             return tr
 
-    # modified from test_browserwidget.BrowserWidgetTest:
-    def verifyResult(self, result, check_list):
-        """Ensure that each element of check_list is present in result."""
-        for check in check_list:
-            self.assert_(result.find(check) >= 0,
-                         "%r not found in %r" % (check, result))
-
-    def verifyResultMissing(self, result, check_list):
-        """Ensure that each element of check_list is omitted from result."""
-        for check in check_list:
-            self.assert_(result.find(check) < 0,
-                         "%r unexpectedly found in %r" % (check, result))
-
 
 class SingleSelectionViews:
     """Mixin that registers single-selection views."""
@@ -216,14 +160,16 @@
                     IBrowserPresentation,
                     vocabularywidget.VocabularyFieldEditWidget)
         # Register the "basic" widgets:
-        provideView(IVocabulary,
+        provideView(IVocabularyTokenized,
                     "field-display-widget",
                     IBrowserPresentation,
                     vocabularywidget.VocabularyDisplayWidget)
-        provideView(IVocabulary,
+        provideView(IVocabularyTokenized,
                     "field-edit-widget",
                     IBrowserPresentation,
-                    vocabularywidget.VocabularyEditWidget)
+                    # XXX indirect through a derived class to allow
+                    # testing of multiple concrete widgets
+                    self.singleSelectionEditWidget)
         provideView(IIterableVocabularyQuery,
                     "widget-query-helper",
                     IBrowserPresentation,
@@ -243,32 +189,32 @@
         # This is equivalent to the default configuration for
         # vocabulary field view registration from configure.zcml.
         # Multi-selection views only.
-        provideView(IVocabularyMultiField,
+        provideView(IVocabularyListField,
                     "display",
                     IBrowserPresentation,
-                    vocabularywidget.VocabularyMultiFieldDisplayWidget)
-        provideView(IVocabularyMultiField,
+                    vocabularywidget.VocabularyListFieldDisplayWidget)
+        provideView(IVocabularyListField,
                     "edit",
                     IBrowserPresentation,
-                    vocabularywidget.VocabularyMultiFieldEditWidget)
+                    vocabularywidget.VocabularyListFieldEditWidget)
         # Bind widgets to the vocabulary fields:
-        provideView(IVocabulary,
-                    "field-display-multi-widget",
+        provideView(IVocabularyTokenized,
+                    "field-display-list-widget",
                     IBrowserPresentation,
-                    vocabularywidget.VocabularyMultiDisplayWidget)
-        provideView(IVocabulary,
-                    "field-edit-multi-widget",
+                    vocabularywidget.VocabularyListDisplayWidget)
+        provideView(IVocabularyTokenized,
+                    "field-edit-list-widget",
                     IBrowserPresentation,
                     vocabularywidget.VocabularyMultiEditWidget)
         provideView(IIterableVocabularyQuery,
-                    "widget-query-multi-helper",
+                    "widget-query-list-helper",
                     IBrowserPresentation,
                     vocabularywidget.IterableVocabularyQueryMultiView)
         # The following widget registration supports the specific
         # sample vocabulary we're using, used to demonstrate how to
         # override widget selection based on vocabulary:
         provideView(ISampleVocabulary,
-                    "field-display-multi-widget",
+                    "field-display-list-widget",
                     IBrowserPresentation,
                     SampleDisplayWidget)
 
@@ -277,33 +223,42 @@
     """Base class for the general widget tests (without query support)."""
 
     def test_vocabulary_specialization(self):
-        bound = self.makeField(SampleVocabulary(["frobnication"]))
+        bound = self.makeField(SampleVocabulary.fromValues(["frobnication"]))
         w = getView(bound, "display", self.makeRequest())
         self.assertEqual(w(), "foo")
 
 
-class SingleSelectionTests(SingleSelectionViews, SelectionTestBase):
+class SingleSelectionTestsBase(SingleSelectionViews, SelectionTestBase):
     """Test cases for basic single-selection widgets."""
 
     defaultFieldValue = "splat"
     fieldClass = vocabulary.VocabularyField
 
+    sampleVocabulary = vocabulary.SimpleVocabulary.fromValues(
+        ["splat", "foobar"])
+
     def test_display(self):
-        bound = self.makeField(BasicVocabulary(["splat", "foobar"]))
+        bound = self.makeField()
         w = getView(bound, "display", self.makeRequest())
+        w.setData(bound.context.f)
         self.assertEqual(w(), "splat")
 
     def test_display_with_form_value(self):
-        bound = self.makeField(BasicVocabulary(["splat", "foobar"]))
+        bound = self.makeField()
         request = self.makeRequest('field.f=foobar')
         w = getView(bound, "display", request)
         self.assert_(w.haveData())
         self.assertEqual(w(), "foobar")
 
-    def test_edit(self):
-        bound = self.makeField(BasicVocabulary(["splat", "foobar"]))
+    def setup_edit(self, bound):
         w = getView(bound, "edit", self.makeRequest())
+        w.setData(bound.context.f)
         self.assert_(not w.haveData())
+        return w
+
+    def test_edit(self, extraChecks=[]):
+        w = self.setup_edit(self.makeField())
+        self.assertEqual(w.getData(), None)
         self.verifyResult(w(), [
             'selected="selected"',
             'id="field.f"',
@@ -312,7 +267,34 @@
             '>splat<',
             'value="foobar"',
             '>foobar<',
+            ] + extraChecks)
+        s0, s1, s2 = w.renderItems("foobar")
+        self.verifyResult(s0, [
+            "value=''",
+            "no value",
+            ])
+        self.verifyResult(s1, [
+            'value="splat"',
+            '>splat<',
+            ])
+        self.assert_(s1.find('selected') < 0)
+        self.verifyResult(s2, [
+            'selected="selected"',
+            'value="foobar"',
+            '>foobar<',
             ])
+
+    def test_edit_required(self, extraChecks=[]):
+        w = self.setup_edit(self.makeField(required=True))
+        self.verifyResult(w(), [
+            'selected="selected"',
+            'id="field.f"',
+            'name="field.f"',
+            'value="splat"',
+            '>splat<',
+            'value="foobar"',
+            '>foobar<',
+            ] + extraChecks)
         s1, s2 = w.renderItems("foobar")
         self.verifyResult(s1, [
             'value="splat"',
@@ -326,29 +308,54 @@
             ])
 
     def test_edit_with_form_value(self):
-        bound = self.makeField(BasicVocabulary(["splat", "foobar"]))
+        bound = self.makeField()
         request = self.makeRequest('field.f=foobar')
         w = getView(bound, "edit", request)
         self.assert_(w.haveData())
-        self.assertEqual(w._showData(), "foobar")
+        self.assertEqual(w.getData(), "foobar")
         self.assert_(isinstance(w, vocabularywidget.VocabularyEditWidget))
-        self.verifyResult(w.hidden(), [
-            '<input',
-            'id="field.f"',
-            'name="field.f"',
-            'value="foobar"',
-            ])
+
+    def test_edit_with_modified_empty_value(self):
+        # This tests that emptying a value via the form when there's a
+        # non-empty value for the field on the content object will
+        # report haveData() properly.
+        bound = self.makeField()
+        bound.context.f = "splat"
+        w = getView(bound, "edit", self.makeRequest(
+            'field.f-empty-marker='))
+        self.assert_(w.haveData())
+        self.assertEqual(w.getData(), None) # XXX might be []...
+
+class SingleSelectionTests(SingleSelectionTestsBase):
+    """Test single-selection with the selection-box widget."""
+
+    singleSelectionEditWidget = vocabularywidget.SelectListWidget
+
+
+class DropdownSelectionTests(SingleSelectionTestsBase):
+    """Test single-selection with the dropdown-list widget."""
+
+    singleSelectionEditWidget = vocabularywidget.DropdownListWidget
+
+    def test_edit(self):
+        SingleSelectionTestsBase.test_edit(self, extraChecks=['size="1"'])
+
+    def test_edit_required(self):
+        SingleSelectionTestsBase.test_edit_required(
+            self, extraChecks=['size="1"'])
 
 
 class MultiSelectionTests(MultiSelectionViews, SelectionTestBase):
     """Test cases for basic multi-selection widgets."""
 
     defaultFieldValue = ["splat"]
-    fieldClass = vocabulary.VocabularyMultiField
+    fieldClass = vocabulary.VocabularyListField
+    sampleVocabulary = vocabulary.SimpleVocabulary.fromValues(
+        ["splat", "foobar", "frob"])
 
     def test_display_without_value(self):
-        bound = self.makeField(BasicVocabulary(["splat", "foobar", "frob"]),
-                               None)
+        bound = self.makeField()
+        del bound.context.f
         w = getView(bound, "display", self.makeRequest())
         self.assert_(not w.haveData())
         self.verifyResult(w(), [
@@ -359,9 +366,9 @@
             ])
 
     def test_display_with_value(self):
-        bound = self.makeField(BasicVocabulary(["splat", "foobar", "frob"]),
-                               ["foobar", "frob"])
+        bound = self.makeField(value=["foobar", "frob"])
         w = getView(bound, "display", self.makeRequest())
+        w.setData(bound.context.f)
         self.assert_(not w.haveData())
         self.verifyResult(w(), [
             '<ol',
@@ -380,8 +387,7 @@
             ])
 
     def test_display_with_form_data(self):
-        bound = self.makeField(BasicVocabulary(["splat", "foobar", "frob"]),
-                               ["foobar", "frob"])
+        bound = self.makeField(value=["foobar", "frob"])
         request = self.makeRequest('field.f:list=splat')
         w = getView(bound, "display", request)
         self.assert_(w.haveData())
@@ -399,7 +405,7 @@
         self.assert_(s.find("frob") < 0)
 
     def test_edit(self):
-        bound = self.makeField(BasicVocabulary(["splat", "foobar", "frob"]))
+        bound = self.makeField()
         w = getView(bound, "edit", self.makeRequest())
         self.assert_(not w.haveData())
         self.verifyResult(w(), [
@@ -430,22 +436,13 @@
         self.assert_(s3.find('selected') < 0)
 
     def test_edit_with_form_value(self):
-        bound = self.makeField(BasicVocabulary(["splat", "foobar", "frob"]))
+        bound = self.makeField()
         request = self.makeRequest('field.f:list=foobar&field.f:list=splat')
         w = getView(bound, "edit", request)
         self.assert_(w.haveData())
-        L = w._showData()
+        L = w.getData()
         L.sort()
         self.assertEqual(L, ["foobar", "splat"])
-        s = w.hidden()
-        self.verifyResult(s, [
-            '<input',
-            'type="hidden"',
-            'name="field.f:list"',
-            'value="foobar"',
-            'value="splat"',
-            ])
-        self.assert_(s.find("frob") < 0)
 
 
 class QuerySupportTestBase(VocabularyWidgetTestBase):
@@ -456,19 +453,22 @@
     mechanics.
     """
 
-    queryableVocabulary = QueryVocabulary(["splat", "foobar", "frob"])
+    sampleVocabulary = QueryVocabulary.fromValues(
+        ["splat", "foobar", "frob"])
 
     def test_get_query_helper(self):
-        bound = self.makeField(self.queryableVocabulary)
+        bound = self.makeField()
         request = self.makeRequest()
         w = getView(bound, "edit", request)
         self.assert_(isinstance(w.query, MyVocabularyQuery))
+        self.assert_(w.queryview.widget is w)
         self.assertEqual(w.queryview.name, w.name + "-query")
-        self.assertEqual(w.queryview.getLabel(), self.queryViewLabel)
+        self.assertEqual(w.queryview.label, self.queryViewLabel)
 
     def test_query_input_section(self):
-        bound = self.makeField(self.queryableVocabulary)
+        bound = self.makeField()
         w = getView(bound, "edit", self.makeRequest())
+        w.setData(bound.context.f)
         checks = [
             "this-is-query-input",
             ]
@@ -476,8 +476,9 @@
         self.verifyResult(w(), checks + ['class="queryinput"'])
 
     def test_query_output_section_without_results(self):
-        bound = self.makeField(self.queryableVocabulary)
+        bound = self.makeField()
         w = getView(bound, "edit", self.makeRequest())
+        w.setData(bound.context.f)
         checks = [
             "query-results-go-here",
             ]
@@ -485,8 +486,9 @@
         self.verifyResultMissing(w(), checks + ['class="queryresults"'])
 
     def test_query_output_section_with_results(self):
-        bound = self.makeField(self.queryableVocabulary)
+        bound = self.makeField()
         w = getView(bound, "edit", self.makeRequest("field.f-query=foo"))
+        w.setData(bound.context.f)
         checks = [
             "query-results-go-here",
             ]
@@ -501,6 +503,7 @@
     defaultFieldValue = "splat"
     fieldClass = vocabulary.VocabularyField
     queryViewLabel = "single"
+    singleSelectionEditWidget = vocabularywidget.VocabularyEditWidget
 
     def registerViews(self):
         SingleSelectionViews.registerViews(self)
@@ -515,23 +518,24 @@
     """Query support tests for multi-selection widgets."""
 
     defaultFieldValue = ["splat"]
-    fieldClass = vocabulary.VocabularyMultiField
+    fieldClass = vocabulary.VocabularyListField
     queryViewLabel = "multi"
 
     def registerViews(self):
         MultiSelectionViews.registerViews(self)
         provideView(IMyVocabularyQuery,
-                    "widget-query-multi-helper",
+                    "widget-query-list-helper",
                     IBrowserPresentation,
                     MyQueryViewMulti)
 
 
 def test_suite():
     suite = unittest.makeSuite(SingleSelectionTests)
+    suite.addTest(unittest.makeSuite(DropdownSelectionTests))
     suite.addTest(unittest.makeSuite(MultiSelectionTests))
     suite.addTest(unittest.makeSuite(SingleSelectionQuerySupportTests))
     suite.addTest(unittest.makeSuite(MultiSelectionQuerySupportTests))
     return suite
 
 if __name__ == '__main__':
-    unittest.main()
+    unittest.main(defaultTest="test_suite")